ValueError: expected 4D input (got 3D input) (Different)

According to this link, we need to give the input to the layer in the format of (Batch x the_size). But what I have worked with Pytorch, it is always able to recognize the difference between Batched-Input and Non-Batched Input(also as you said).

  • So why it this point we need to define an extra dimension for batch before passing to the layer.
  • If it can already create the distinct output for Batched(4D Input) and Non-Batched(3D Input), then why it is throwing a Value Error.
  • If it can process both the 4D Input and 3D Input ,why it expecting 4D Input.

The specific Layer I was getting Issue with was Batch Norm 2d

Sorry for replying Late : )