Thank you for the quick reply.
While implementing using inheritance from nn.Module, for some reason the gradients weren’t flowing backwards. Is there any particular reason for this? Do we need to declare any variables in the constructor for it to work? (Since activations take input and pass it through non-linearity, I didn’t declare any variables in the constructor. I had only written the forward() function for it. Could this be a reason for no gradients being calculated?)