Few questions regarding first GAN assignment

Yes, there is a lot to learn if you are new to PyTorch. They did provide a PyTorch optional tutorial earlier in Week 1, but I don’t remember if they cover the issues you raise.

For the question about the forward() method, you should read the pytorch doc for the class nn.Module, of which all our networks are subclasses. They specifically say that you should invoke the actual model instance as a function instead of directly calling the forward() method. Have a look at what it says under the forward() method in that document.

For the second question, I’m not sure what you mean by “strings attached”, but note that we have to write the loss functions and they are defined in terms of the output of the generator and discriminator and the criterion functions. So the compute graphs are defined by that. PyTorch (like TF and other frameworks) computes gradients for you automatically, when you run in “training” mode, but there is some additional logic you need to add to actually apply the gradients appropriately. Have a look at the training code: they give you some worked examples and then you have to copy those for the parts you need to write. Look at the zero_grad(), step() and backward() methods. That is where the action happens of applying (or not) the automatically computed gradients.

There are also some subtleties and complexities specific to GANs: we train the generator and the discriminator separately and alternately, but training the generator involves the gradients of the discriminator by definition. We need to be careful not to actually apply those gradients when we are training the generator. Here’s a thread which discusses that in more detail.

The pytorch documentation is good and there is an active online support community. If you’d like a more thorough intro about back prop in pytorch, you can google up some overall explanations on how gradients work in pytorch.