You can use -1 in view so that the remaining dimension is automatically calculated, but instead of using it in the first dimension, which you know and is the batch size, you use it the the other one.
For example
bs = 5
x = torch.rand(bs, 3, 224, 224)
x = x.view(x.size(0), -1)