Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def conv_block(x, n_filters, pool_size=(2, 2)):
- x = Conv2D(n_filters, (3, 3), strides=(1, 1), padding='same')(x)
- x = Activation('relu')(x)
- x = MaxPooling2D(pool_size=pool_size, strides=pool_size)(x)
- x = Dropout(0.25)(x)
- return x
- # Model Definition
- def create_model(input_shape, num_genres):
- inpt = Input(shape=input_shape)
- x = conv_block(inpt, 16)
- x = conv_block(x, 32)
- x = conv_block(x, 64)
- x = conv_block(x, 128)
- # Global Pooling and MLP
- x = Flatten()(x)
- x = Dropout(0.40)(x)
- x = Dense(20, activation='relu',
- kernel_regularizer=tf.keras.regularizers.l2(0.04))(x)
- x = Dropout(0.25)(x)
- predictions = Dense(num_genres,
- activation='softmax',
- kernel_regularizer=tf.keras.regularizers.l2(0.04))(x)
- model = Model(inputs=inpt, outputs=predictions)
- return model
- model = create_model(X_train[0].shape, 3)
Advertisement
Add Comment
Please, Sign In to add comment