Thanks a lot for your help. I fixed the part you suggested and I am getting the same errors. I do have a pretty complex loss function, which involves a calculation of loss after applying cumulative sum, upsampling, and warping operations to the output of the network. Since backward() tracks gradients from the endpoint of the loss function, would it be possible that some problem in one of the post-processing operations cause ‘x’ in the forward operation to loose its gradients?