Najyer

Untitled

Feb 27th, 2023
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | Source Code | 0 0
  1. def conv_block(x, n_filters, pool_size=(2, 2)):
  2. x = Conv2D(n_filters, (3, 3), strides=(1, 1), padding='same')(x)
  3. x = Activation('relu')(x)
  4. x = MaxPooling2D(pool_size=pool_size, strides=pool_size)(x)
  5. x = Dropout(0.25)(x)
  6. return x
  7. # Model Definition
  8. def create_model(input_shape, num_genres):
  9. inpt = Input(shape=input_shape)
  10. x = conv_block(inpt, 16)
  11. x = conv_block(x, 32)
  12. x = conv_block(x, 64)
  13. x = conv_block(x, 128)
  14.  
  15. # Global Pooling and MLP
  16. x = Flatten()(x)
  17. x = Dropout(0.40)(x)
  18. x = Dense(20, activation='relu',
  19. kernel_regularizer=tf.keras.regularizers.l2(0.04))(x)
  20. x = Dropout(0.25)(x)
  21. predictions = Dense(num_genres,
  22. activation='softmax',
  23. kernel_regularizer=tf.keras.regularizers.l2(0.04))(x)
  24.  
  25. model = Model(inputs=inpt, outputs=predictions)
  26. return model
  27. model = create_model(X_train[0].shape, 3)
Advertisement
Add Comment
Please, Sign In to add comment