Code :-

models = keras.Sequential(
        layers.Dense(512,activation = 'relu'),
        layers.Dense(256,activation = 'relu'),

    metrics = ["accuracy"]



Epoch 1/5
1875/1875 - 8s - loss: 0.1854 - accuracy: 0.9450
Epoch 2/5
1875/1875 - 11s - loss: 0.0790 - accuracy: 0.9760
Epoch 3/5
1875/1875 - 7s - loss: 0.0561 - accuracy: 0.9822
Epoch 4/5
1875/1875 - 6s - loss: 0.0423 - accuracy: 0.9865
Epoch 5/5
1875/1875 - 6s - loss: 0.0329 - accuracy: 0.9893

<tensorflow.python.keras.callbacks.History at 0x7efda0e109a0>

While learning TensorFlow, My first doubt was what is accuracy and loss? By google, I Learned:- Loss value implies how poorly or well a model behaves after each iteration of optimization. An accuracy metric is used to measure the algorithm's performance in an interpretable way. The accuracy of a model is usually determined after the model parameters and is calculated in the form of a percentage.

But my doubt is how TF knows about accuracy as we pass only training data, not Test Data. To calculate accuracy I think test data needed. Is TF split train data into another train and test data?

  • $\begingroup$ "To calculate accuracy I think test data needed" - this is just wrong; depending on the dataset used, there is the training accuracy and the test (or validation) accuracy, and what TF reports here is obviously the former. Had you passed also a validation set to model.fit(), you would get two more reported quantities, val_loss and val_accuracy in the output. $\endgroup$
    – desertnaut
    Feb 13, 2021 at 12:52

1 Answer 1


You are still able to calculate metrics such as loss and accuracy on training data (or any data for that matter), however the important thing to keep in mind is that it is by definition training data. Therefore the metrics from the training data are not how you would expect the model to perform on new unseen data as the model has been training on these specific samples (and can possibly remember them).

  • $\begingroup$ Can't Understand. $\endgroup$
    – Ujjwal Kar
    Feb 11, 2021 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.