The Conv2d class only takes 4 dimensional inputs that’s why.
The inputs should be formated this way :
[batch_size, channels, height, width] if your want your forward to work.
For more information see the doc 
https://pytorch.org/docs/stable/nn.html 1