I am troubled with debugging Nan.
The easiest way to debug it is to monitor the model parameter grad (for example using hook).
However, all parameters are updated to nan at the same time, and it is difficult to identify the cause by the usual method.
In my model, loss is calculated by applying self-made function consisted of several formal torch.Tensor for output of model defined by nn.
For that update, we perform backpropagation with backward () by Autograd.
I doubt that nan is occurring during the backward and want to identify the cause.
(Nan does not occur in the process of inference normally.)
So, I would like to know how to monitor the propagation of grad in my own function composed of several torch.Tensors (print each value of grad).