TransWikia.com

Is my CNN model overfitting?

Data Science Asked by SmallChess on March 24, 2021

enter image description here

I’m training a standard CNN. Attached my training curve. My model:

Model: "functional_35"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input_18 (InputLayer)        [(None, 120, 120, 3)]     0         
_________________________________________________________________
conv2d_28 (Conv2D)           (None, 118, 118, 32)      896       
_________________________________________________________________
max_pooling2d_28 (MaxPooling (None, 59, 59, 32)        0         
_________________________________________________________________
dropout_23 (Dropout)         (None, 59, 59, 32)        0         
_________________________________________________________________
flatten_17 (Flatten)         (None, 111392)            0         
_________________________________________________________________
dense_17 (Dense)             (None, 256)               28516608  
_________________________________________________________________
visualized_layer (Dense)     (None, 1)                 257       
=================================================================
Total params: 28,517,761
Trainable params: 28,517,761
Non-trainable params: 0
_________________________________________________________________

My data dimension:

enter image description here

Is my model overfitting, if so, what’s my best strategy now?

One Answer

Your train/validation loss curves are a classic example of overfitting.

It looks like you have 1425 data samples to train a model with > 28 million parameters.

I would suggest trying any/all of the follow:

  1. use a smaller model -> less parameters means less complexity and less ability to overfit
  2. data augmentation -> more data samples means more variation in the dataset for the model to capture
  3. early-stopping -> use something like the Keras callback, which will stop the model training once the validation loss doesn't decrease for a number of epochs

If you happen to be using image data, you might take a look at the Keras ImageDataGenerator, which can do things like flip/rotate your images.

Correct answer by n1k31t4 on March 24, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP