Which metrics are printed (train or validation) when validation_split and validation_data is not specified in the keras model.fit function?
Question:
I have a TF neural network and I am using the tf.data
API to create the dataset using a generator. I am not passing validation_split
and validation_data
into the model.fit()
function of keras.
The default values for the above parameter are 0.0
and None
respectively. So, I am not sure about the metrics (precision, recall, etc) that get printed after model.fit()
, are those training metrics or validation metrics? According to my understanding, those shouldn’t be validation metrics as I am using the default values for the mentioned arguments.
Here’s what I am referring to –
Epoch 1/50 10/10 [==============================] - 6119s 608s/step - loss: 0.6588 - accuracy: 5.4746e-06 - precision: 0.0095 - recall: 0.3080
Tensorflow doc for model.fit()
Answers:
By default, the metrics that get printed after calling model.fit()
are training metrics. The validation_split
argument determines the fraction of the training data to be used as validation data, and validation_data
allows you to specify a separate validation set. When either of these arguments is set, the model will use them to compute validation metrics, which will be printed along with the training metrics. However, if neither argument is set, the model will only use the training data to compute the metrics, which will be the training metrics. In your case, since you have not set either argument, the metrics that get printed are indeed training metrics.
Edit
When you pass either of validation_split
or validation_data
you could see validation metrics in addition to training metrics. This is how it would look –
29/29 [==============================] - 0s 12ms/step - loss: 0.0882 - accuracy: 0.0000e+00 - precision_2: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 0.0557 - val_accuracy: 0.0000e+00 - val_precision_2: 0.0000e+00 - val_recall_2: 0.0000e+00
I have a TF neural network and I am using the tf.data
API to create the dataset using a generator. I am not passing validation_split
and validation_data
into the model.fit()
function of keras.
The default values for the above parameter are 0.0
and None
respectively. So, I am not sure about the metrics (precision, recall, etc) that get printed after model.fit()
, are those training metrics or validation metrics? According to my understanding, those shouldn’t be validation metrics as I am using the default values for the mentioned arguments.
Here’s what I am referring to –
Epoch 1/50 10/10 [==============================] - 6119s 608s/step - loss: 0.6588 - accuracy: 5.4746e-06 - precision: 0.0095 - recall: 0.3080
Tensorflow doc for model.fit()
By default, the metrics that get printed after calling model.fit()
are training metrics. The validation_split
argument determines the fraction of the training data to be used as validation data, and validation_data
allows you to specify a separate validation set. When either of these arguments is set, the model will use them to compute validation metrics, which will be printed along with the training metrics. However, if neither argument is set, the model will only use the training data to compute the metrics, which will be the training metrics. In your case, since you have not set either argument, the metrics that get printed are indeed training metrics.
Edit
When you pass either of validation_split
or validation_data
you could see validation metrics in addition to training metrics. This is how it would look –
29/29 [==============================] - 0s 12ms/step - loss: 0.0882 - accuracy: 0.0000e+00 - precision_2: 0.0000e+00 - recall_2: 0.0000e+00 - val_loss: 0.0557 - val_accuracy: 0.0000e+00 - val_precision_2: 0.0000e+00 - val_recall_2: 0.0000e+00