I’m trying to define a autograd function. In the forward path, I want to compute the gradient of a LSTMCell’s output with respect to its input. So I called autogard.grad, however I got error " element 0 of tensors does not require grad and does not have a grad_fn". I already set “requires_grad = True” for the input, not sure why this error occur.
I attach my code here for further refer:

Screen Shot 2019-04-29 at 7.00.19 PM.png1232×846 114 KB

Thanks in advance!