If you need to keep more dimensions, you shouldn’t use the -1 in the second argument to view, but provide the desired shapes instead.
The important part is to keep the batch dimension equal via input.view(input.size(0), ...), since this is currently raising the shape mismatch error.