When i use  “with autograd.detect_anomaly()” i get the following error messages:

RuntimeError: Function 'Sigmoidbackward' returned  nan values in its 0th output

RuntimeError: Function 'DivBackward0' returned nan values in its 0th output

RuntimeError: Function 'CudnnConvolutionBackward' returned nan values in its 0th output

RuntimeError: Function torch::jit::(anonymous namespace)::DifferentiableGraphBackward returned nan values in its 2th output

Can anyone tell me if it is caused by overflow/division by zero ,etc.?
Edit: I narrowed it down, the problem is in the following lines, but still can’t resolve it:
ingate = ingate + ingate_2
forgetgate = forgetgate + forgetgate_2
outgate = outgate + (torch.mm(cy-cx, self.weight_ch_dc_cur.t()) + self.bias_ch_dc_cur + torch.mm(cy, self.weight_ch_cur.t()) + self.bias_ch_cur )