AlphaBetaGamma96:

loss_as_numpy_array = loss.clone().detach().numpy() #copy and detach
loss.backward() #backprop loss



Also following on what @zilong said, make sure you don’t detach the gradients you want to compute. You stated you want a copy for numpy and one for gradients, make sure the numpy version is detached and the one that propagates through to the loss is not detach!