0

I want to make an image classifier using CNN. There are two types of images in the dataset: men and women. in total there are 2300 images, 20% of which I used for validation. the problem is that my model isn't good at all because of overfitting(I think that's the problem) but I cant figure out why my model overfits so badly(please open the link of the graph below. maximum value of y is 3.5) here's the keras model I used to make bicategorical predictions

early_stopping = EarlyStopping(min_delta = 0.001, patience = 20, restore_best_weights = True)
model = tf.keras.Sequential()   
model.add(tf.keras.layers.Conv2D(64, (3, 3), activation = 'relu'))  
model.add(tf.keras.layers.MaxPooling2D((2, 2)))
model.add(tf.keras.layers.Conv2D(64, (3, 3), activation = 'relu'))  
model.add(tf.keras.layers.MaxPooling2D((2, 2)))
model.add(tf.keras.layers.Flatten())
model.add(tf.keras.layers.Dense(32, activation = 'relu'))
model.add(tf.keras.layers.Dropout(0.25))
model.add(tf.keras.layers.Dense(32, activation = 'relu'))
model.add(tf.keras.layers.Dropout(0.25))
model.add(tf.keras.layers.Dense(2, activation = 'softmax'))
opt = keras.optimizers.Adam(learning_rate=0.01)
model.compile(optimizer = 'adam', loss = 'sparse_categorical_crossentropy', metrics = ['accuracy']) 
history = model.fit(xtrain, ytrain, validation_data = (xval, yval), batch_size = 16, epochs = 100, callbacks = [early_stopping], verbose = 0)

I usually get this kind of results

bearthum
  • 107
  • 2
  • 10
  • Please, add more details. – Innat Dec 10 '20 at 17:30
  • Judging from the title, it looks like you are increasing the learning rate. If your goal is to reduce overfitting, then you should *decrease* the learning rate. – Arturo Sbr Dec 10 '20 at 18:12
  • What I thought was that maybe the dataset is too small so the model can't learn at all. that's why I tried increasing lr a little bit. – bearthum Dec 10 '20 at 18:22

0 Answers0