Hi, I recently went through an error where I created one nn.Linear layer but didn’t use it in forward.
It turns out that net.parameters() generates parameters for this layer also. So, when I tried to update using for p in model.parameters(): p -= p.grad * 0.001 this gave me error TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'. I resolved this by commenting the unused layer in init.
Since my loss was not depending upon unused layer gradients were none.
This is for pytorch_1.16_cpu