Please note everyone, that this is a "Multi-Label" problem as opposed to Multi-Class. It's a multi-label, multi-class problem. I am trying to classify movie posters by genre by reading the images alone. I have over 22000 images overall. I have one hot encoded the genres for the Keas model to predict multiple genres for movies (Used sigmoid in final dense layer activation). I need recommendation for a proper batch size and number of epochs. I am using VGG16. I would also like to know how to choose which layers to freeze.
I have tried for 25 epochs using VGG16. The model tends to over-fit though. Batch size was 10.
Here's my training images count by genre (Note: A movie could be more than one genre which is more often than not, the case)
{'Action': 2226.0, 'Thriller': 2788.0, 'Drama': 9283.0, 'Romance': 2184.0, 'Horror': 2517.0, 'Sci-Fi': 756.0, 'Mystery': 918.0, 'Adventure': 1105.0, 'Animation': 583.0, 'Crime': 1369.0, 'Comedy': 5524.0, 'Fantasy': 735.0, 'Family': 991.0, 'Music': 319.0, 'History': 359.0, 'War': 177.0, 'Musical': 191.0, 'Biography': 484.0, 'Sport': 190.0}
conv_base = VGG16(weights = 'imagenet', include_top = False, input_shape = (224,224,3))
for layer in conv_base.layers[6:]:
layer.trainable = False
early = EarlyStopping(monitor='acc', patience=7, mode='auto')
classifier = Sequential()
classifier.add(conv_base)
from keras.layers import Dropout
classifier.add(Dense(units = 128, activation = "relu"))
classifier.add(Dropout(0.2))
classifier.add(Dense(units = 128, activation = "relu"))
classifier.add(Dropout(0.1))
classifier.add(Dense(units = 19, activation = 'sigmoid'))
classifier.compile(optimizer = 'adam', loss = 'binary_crossentropy', metrics = ["accuracy"])
classifier.fit(X_train, y_train, epochs=15, batch_size=10, callbacks = [early])