Thanks @ptrblck. I realized this after posting the question. Anyway, I have a new issue now on the very same lines. When I try to do a prediction on a single image, after preprocessing it the way PyTorch Transforms are doing, I get a size mismatch error. Exemplifying:
This is the shape of one batch from the dataloader: torch.Size([32, 3, 224, 224])
This is the shape of the image after preprocessing it: torch.Size([3, 224, 224])
When I try to predict this, I get the following error:
RuntimeError: expected stride to be a single integer value or a list of 1 values to match the convolution dimensions, but got stride=[1, 1]
Looking at your answer on other threads, I did add unsqueeze_(0) which leads to this error:
ValueError: Expected input batch_size (1) to match target batch_size (32)
Please help me with this.
P.S. I understand if one solution is to increase the size in 0th dimension to 32 (Please show me how to do it) but I am not able to understand why PyTorch cannot recognize the batch size to be independent of the input. Why does it care about the batch size?