I would like to monitor the gradient changes in tensorboard with keras to decide whether gradient vanish or explosion. What should I do?
To visualize the training in Tensorboard, add keras.callbacks.TensorBoard
callback to model.fit
function. Don't forget to set write_grads=True
to see the gradients there. Right after training start, you can run...
tensorboard --logdir=/full_path_to_your_logs
... from the command line and point your browser to htttp://localhost:6006
. See the example code in this question.
To check for vanishing / exploding gradients, pay attention the gradients distribution and absolute values in the layer of interest ("Distributions" tab):
NaN
s very quickly as well.