Hi Abhisek!



 abhisek:

        gt = predictions.clone().zero_()

Possibly this is due to zero_() call since it is an in place operation.


This is likely the problem.  (.clone() without .detach() is still part
of the computation graph, and you then .zero_() the cloned tensor
in place.)


However, I am not sure how can I fix this.


It looks like you want to initialize gt as a zero-tensor of the same
shape as predictions.  Try:
gt = torch.zeros_like (predictions)

Best.
K. Frank