Hi,
I think the following issue is happening. Suppose I have a NN with 2 layers, call it L1 and L2.
Now, for a data point x, I either use
NN1(x)–>NN2(x)–> output
or
NN2(x)–> output
or
x --> output
Now, it turns out that not every parameter of NN1 and NN2 is used for each data point.
It turns out that when a neural network parameter is not used in the forward pass, its parameter.grad is None. This is the reason that I am getting error. Seems very hard to get rid of. I am stuck in this.