Getting RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn but the element 0 in my case is just a tensor of fixed float values that only needs to be subtracted from nn.Parameter and hence, does not need the grad_fn

Small detail: You should not do param.data.cuda() but param.detach().cuda(). As .data should not be used anymore.

1 Like