How tensorflow understand accuracy and loss of training data? Code :-
models = keras.Sequential(
    [
        keras.Input(shape=(28*28)),
        layers.Dense(512,activation = 'relu'),
        layers.Dense(256,activation = 'relu'),
        layers.Dense(10),
    ]
)

models.compile(
    loss=keras.losses.SparseCategoricalCrossentropy(from_logits=True),
    optimizer=keras.optimizers.Adam(lr=0.001),
    metrics = [&quot;accuracy&quot;]
)

models.fit(x_train,y_train,batch_size=32,epochs=5,verbose=2)

Output:-
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

&lt;tensorflow.python.keras.callbacks.History at 0x7efda0e109a0&gt;

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?
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).