Can accuracy/loss curve be less fluctuating? CNN

Viewed 15

I have a classification problem with 2 balanced classes, that have 20000 images with 70% train 20% val and 10% for later testing splittet using train_test_split. My CNN model is fluctuating from the start and I tried to stabilize it with Dropout, optimizers, learning rate, batch_size with diffrent parameters and dont have idea what can I do more

[loss]https://i.stack.imgur.com/Hz6GS.png

[accuracy]https://i.stack.imgur.com/AwkjZ.png

[classification_report]https://i.stack.imgur.com/67MwM.png

[model_structure]https://i.stack.imgur.com/0hs6y.png

model = Sequential()
model.add(Conv2D(32, (3, 3), input_shape=(50, 50, 3), activation='relu', kernel_initializer="glorot_uniform", kernel_constraint=max_norm(3)))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Dropout(0.2))
model.add(Conv2D(32, (3, 3), activation='relu', kernel_initializer="glorot_uniform", kernel_constraint=max_norm(3)))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Dropout(0.2))
model.add(Flatten())
model.add(Dropout(0.2))
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.2))
model.add(Dense(2, activation='softmax'))
model.compile(loss='binary_crossentropy', optimizer=Adam(), metrics=['accuracy'])
model.summary()

history = model.fit(X_train, y_train, 
      validation_data = (X_test, y_test), 
      epochs = 300,
      verbose = 1,
      batch_size = 1000)
1 Answers

You can try to lower the learning_rate of the optimizer. The callbacks LearningRateScheduler and ReduceLROnPlateau might be useful here. You could also try the following:

  • use SpatialDropout2D instead of Dropout between the conv layers
  • use a conv layer with stride 2 instead of a MaxPool layer
Related