Issue
As the title implies, I would like to find out if it is possible to output the accuracy on the test data as well as the training data, to see at which point my model starts to overfit and result in worse performance on test data. However, I do not know how to do this and I was not able to find an answer online.
To train the model, I am making use of the built-in fit
method.
Is this possible? Thank you.
Solution
Generally, it is best to partition your data into a training set, a validation set and a test set. I typically use 80% of the data for the training set, 10% for the validation set and 10% for the test set. model.fit()
provides the ability to specify both a training set and a validation set as parameters. For each epoch of training, TensorFlow will produce a printout of the training accuracy, training loss, validation accuracy and validation loss if you set verbose to either 1 or 2 and you include 'accuracy' as a metric in model.compile()
. You can then look at the loss values (the best to plot them using history.history
) and determine if you are overfitting. There are several ways to develop a validation set. If your data is not produced by generators, you can specify the validation_split parameter in model.fit()
to create a validation set automatically. Alternatively, you can use ImageDataGenerator.flow_from_directory to generate a validation set by setting the parameter validation_split
. Documentation is here.
Answered By - Gerry P
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.