Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does Keras evaluate loss on test set?

Tags:

keras

I am implementing a neural network classifier, to print loss and accuracy of this NN I'm using:

score = model.evaluate(x_test, y_test, verbose=False) 
model.metrics_names
print('Test score: ', score[0])    #Loss on test
print('Test accuracy: ', score[1])

I would to know how Keras calculate the loss of a model. Specially whether it is evaluated on the first (and only) step of the test set. I have search on keras.io, but I don't have find anything about it.

like image 770
Simone Avatar asked Jan 30 '17 15:01

Simone


People also ask

How is Keras test accuracy calculated?

Accuracy calculates the percentage of predicted values (yPred) that match with actual values (yTrue). For a record, if the predicted value is equal to the actual value, it is considered accurate. We then calculate Accuracy by dividing the number of accurately predicted records by the total number of records.

How do you evaluate in Keras?

Keras can separate a portion of your training data into a validation dataset and evaluate the performance of your model on that validation dataset in each epoch. You can do this by setting the validation_split argument on the fit() function to a percentage of the size of your training dataset.

What does model evaluate do in Keras?

Evaluation is a process during development of the model to check whether the model is best fit for the given problem and corresponding data. Keras model provides a function, evaluate which does the evaluation of the model.


1 Answers

From the documentation:

evaluate

Computes the loss on some input data, batch by batch.

Returns

Scalar test loss (if the model has no metrics) or list of scalars (if the model computes other metrics). The attribute model.metrics_names will give you the display labels for the scalar outputs.

So it returns you either a single value that represents a loss, or a list of values that correspond to different metrics that were added to your model. These values are calculated based on the whole test set, i. e. all values in x_test and y_test.

like image 110
Sergii Gryshkevych Avatar answered Jan 04 '23 00:01

Sergii Gryshkevych