JsFlo / EmotionRecTraining

Python script using Keras + TensorFlow to train a custom machine learning model to recognize faces using a dataset with human faces and labeled with emotions.
33 stars 19 forks source link

How to avoid overfitting? #1

Open zzydog1982 opened 6 years ago

zzydog1982 commented 6 years ago

Hi. I'm interested in FER. In your experiment, do you split the dataset into training/validation/testing set? How to avoid overfitting? Thanks!

JsFlo commented 6 years ago

Hi, The data actually comes labeled with "test" and "training" so I use those two sets to train and validate. There are a couple things you could do to prevent overfitting.

The first thing I would try is to bump the drop out or add more drop out (There is a drop out applied to the last dense/fc layers).

Next, I would try stopping the training a little earlier. You could log the "training error" and the "test error" during training and pick out the place (n_epochs) where the test/validation set has a low error.

There are other techniques like gathering more data or changing the architecture that would be slightly more difficult to accomplish. This article goes over some of those: https://elitedatascience.com/overfitting-in-machine-learning

zzydog1982 commented 6 years ago

Thanks a lot. The data in the .csv are labeled with "private test" and "public test". If I can use the date with "private test " as my validation set, and use the other as test set?

JsFlo commented 6 years ago

Yea I used both "public/private test" as my validation set but you should probably separate them like that if you're going to be trying to reduce overfitting/modifying hyperparameters