How to solve issue : grad_fn = None
Could anyone advise why grad_fn = None for this pytorch coding ?


Parameter weights are leaf nodes, i.e. those tensor are not the result of an operation, in other words, there is no other tensor node preceding them. You can check using the is_leaf attribute:
&gt;&gt;&gt; nn.Linear(1,1).weight.is_leaf
True

The grad_fn attribute essentially holds the callback function to backpropagate from a given tensor node. By definition, leaf tensors do not have such function because there is nothing to backpropagate on.
