Question: I want to see the val\_loss and val\_acc while training my model using keras.

```
model.compile(optimizer=optimizer,
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

```

But I only got training loss and accuracy.
I tried to add 'val\_loss', 'val\_accuracy', 'val\_acc', but none of them worked.

Any solution?
Thanks!

Answer: 
According [Keras docs](https://keras.io/models/model/) you do that in `model.fit()` with `validation_data` parameter Here is an example: 

```
# Train model
history = model.fit(
    train_x, train_y,
    batch_size=BATCH_SIZE,
    epochs=EPOCHS,
    validation_data=(validation_x, validation_y),
    callbacks=[tensorboard],
)    

```

Also my advice to use [tensorboard](https://www.machinecurve.com/index.php/2019/11/13/how-to-use-tensorboard-with-keras/) for visualizing the training.
You need to specify the `validation_freq` when calling the `model.fit` method, just set it to `validation_freq=1`, if you want to use it in a callback. And as the other Answer already said, you need of course provide the validation\_data.

Deatails for `model.fit` [Keras Docs](https://keras.io/api/models/model_training_apis/#fit-method)

This should give you 2 more metrics `val_accuracy` and `val_loss` and you can use them in callbacks.

This is an old question so no help for you, but since i got the exact same problem and got here via google i thought i answer, might be useful for someone.