I’m trying to output the hessian of my loss function w.r.t. model parameters for a simple MNL choice model. I get the following error when executing loss.backward the final time: “one of the variables needed for gradient computation has been modified by an inplace operation: [torch.FloatTensor [1, 1]], which is output 0 of TBackward, is at version 9401; expected version 9400 instead.”
model.parameters() contains 2 objects; an embedding of size (70,1) and a (1,1) float, both with requires_grad=True.
attached is a screen show of where the error occurs (in the fit() function at the last loss.backward() call before “with t.no_grad():”)
The hessian computation works just fine as is for a simpler model with only one parameter (the (70,1) embedding). Any help is greatly appreciated!