Session Ready
Exercise

Your first CNN - forward() method

Now that you have declared all the parameters of your CNN, all you need to do is to implement the net's forward() method, and voila, you have your very first PyTorch CNN.

Note: for evaluation purposes, the entire code of the class needs to be in the script. We are using the __init__ method as you have coded it on the previous exercise, while you are going to code the .forward() method here.

Instructions
100 XP
  • Apply the first convolutional layer, followed by the relu nonlinearity, then in the next line apply max-pooling layer.
  • Apply the second convolutional layer, followed by the relu nonlinearity, then in the next line apply max-pooling layer.
  • Transform the feature map from 4 dimensional to 2 dimensional space. The first dimension contains the batch size (-1), deduct the second dimension, by multiplying the values for height, width and depth.
  • Apply the fully-connected layer and return the result.