I am following this document to implement DC GAN DCGAN Tutorial — PyTorch Tutorials 2.2.0+cu121 documentation
However, I am not using num_workers = 2. I am only using Default workers and device is cuda:0.
on training the generator and discriminators I am getting this error:
Here is the code line:
This last line is resulted in throwing this exception.
Please help me in solving this exception. Thank you in advance.
The error is raised in the forward pass, as the missing forward
method cannot be found.
Could you post the definition of netD
so that we could take a look at it?
1 Like
Hi, here is the code snippet:
please have a look. On the top weights are define and in last two models are defined.
I guess, In Discriminator class, you have defined your def forward() inside init(), it should be outside init function.
1 Like
Forward function is immediate after the discriminator but it is not inside init () function!
The forward
method seems to be outside of the model definition, so you would have to add an indentation.
PS: you can post code snippets by wrapping them into three backticks ```, which makes debugging easier.
1 Like
Your forward() method is outside the discriminator class, bring it to the same vertical indent line as the init() method.
1 Like
Thank you so much for replies. It is solved.
1 Like
There was an indentation problem of forward method. It should be same vertical indent line as the init() method.