Yes, your explanation makes sense and I also wanted to point to the view operation, which was most likely wrong.
I would generally recommend to use x = x.view(x.size(0), -1) to keep the batch dimension equal and to flatten the “additional” dimensions. This would then raise a shape mismatch in the linear layer, which is sometimes easier to debug than a batch size mismatch.