RuntimeError: One of the differentiated Tensors appears to not have been used in the graph.

写了个神经网络model 输入是图片的矩阵Pin 输出也是矩阵Pout=model(Pin)
想用pytorch autograd计算Pout gradient with respect to Pin.
Autograd.grad(Pout,Pin,grad_)
输出错误RuntimeError: One of the differentiated Tensors appears to not have been used in the graph.