Skip to main content

Timeline for Overfitting in neural network

Current License: CC BY-SA 3.0

9 events
when toggle format what by license comment
Jul 21, 2017 at 13:53 history migrated from stackoverflow.com (revisions)
Jul 21, 2017 at 13:34 comment added Damith Tilakaratne i found the answer from keras FAQ, they say that, "A Keras model has two modes: training and testing. Regularization mechanisms, such as Dropout and L1/L2 weight regularization, are turned off at testing time. Besides, the training loss is the average of the losses over each batch of training data. Because your model is changing over time, the loss over the first batches of an epoch is generally higher than over the last batches. On the other hand, the testing loss for an epoch is computed using the model as it is at the end of the epoch, resulting in a lower loss."
Jul 20, 2017 at 14:20 comment added Damith Tilakaratne i got a funny graph where train accuracy is lower than val_accuracy and also training loss is higher than validation loss. is this something to do with my data input, like not shuffling the data?
Jul 20, 2017 at 12:00 comment added Neil Slater @DamithTilakaratne: By adding the validation_data parameter when you fit the model e.g. validation_data=(x_test, y_test) - see the example code I linked for context
Jul 20, 2017 at 11:56 comment added Damith Tilakaratne in my case it only print out the loss and accuracy how can i print the val_loss and val_accuracy
Jul 20, 2017 at 11:35 comment added Neil Slater E.g. from that example, if I run it I see one line per epoch: 60000/60000 [==============================] - 8s - loss: 0.2456 - acc: 0.9245 - val_loss: 0.1146 - val_acc: 0.9654 - and you can plot the loss as "training loss" and val_loss as "test loss" for a similar graph. The values are also available programatically from the history variable.
Jul 20, 2017 at 11:33 comment added Neil Slater Keras can output that, you just tell it what test set to use, and what metrics to use. Often in practice this is a 3-way split, train, cross-validation and test, so if you find examples that have a validation or cv set, that is fine to use for the plots too and is a similar example. This example should output train and test metrics on each epoch: github.com/fchollet/keras/blob/master/examples/mnist_mlp.py
Jul 20, 2017 at 10:57 comment added Damith Tilakaratne in my model it has 10 epoch with a batch size of 32 so for each epoch i can get the training loss while training. but i am no familiar with how to get the test loss for epoch. can you please explain that
Jul 20, 2017 at 10:27 history answered Neil Slater CC BY-SA 3.0