Sandeep_Kumar_GITAM:

How can I avoid ‘nan’ values?


You’ll need to check all input Tensors, so check how input_unfold and weight_flat and perhaps even self.gamma are defined/computed. I’d assume it’s coming from input_unfold but check them all.
You can do this easily by usingtorch.autograd.detect_anomaly as a context manager (see more Automatic differentiation package - torch.autograd — PyTorch 1.10.0 documentation 1)