Solved by mailcorahul in post #4 
              
              
                It is because nn.Conv2d in essence uses a 3d filter i.e filter_size x filter_size x input_channels. And as @alan_ayu pointed out, you need filter size, input channels and output channels to define Conv2d’s parameters.