Discriminator Network instance creation generates an error


I have two classifiers and two associated discriminator networks. While I can create the instances of Classifier networks but I can’t in the case of discriminator networks. It generates an “AttributeError: ‘torch.device’ object has no attribute '_apply’”. I’ve seen several related posts and I also checked my PyTorch version which is 1.1.0. I don’t know how to debug this issue. I’ve attached a screenshot of the Jupyter notebook and the Discriminator class. If needed I can provide more detailed information. Can you please help me out?

FYI: The main difference between Classifier and Discriminator class is that the Discriminator network has CNN layers.
Thank you.

You are not creating an instance of the discriminator, i.e. you forgot the parentheses.
Try to call Discriminator().to(DEVICE) instead.

PS: It’s better to post the code directly by wrapping it in three backticks ``` instead of screenshots. This will allow the search to index it and allows us to copy/paste it in case we need to debug it. :wink:

1 Like

Ah! Thank you for point me out the mistake that I did.

Next time I’ll the three back-ticks to wrap up the codes. Thanks again for the suggestion.

1 Like