I am having assertion error for this
assert gen.gen[0][0].weight.grad is None
Does that mean my Generator function is having problem?
Most probably it does have a problem!
Please show us the entire exception trace that you are getting.
But it looks like what that assertion is checking is that you detached the generator, so that gradients will not be accumulated. This is in the section where you are training the discriminator. The point is that in that case you do not need the gradients of the generator. Here’s a thread which talks about why that is.
Thanks a lot Paul. I resolved the issue. I forgot to detach the generator in the function.