I tested this with sample input of size (4, 5, 3, 224, 224) and it does not error out. The error you’re getting is a little bizarre; it implies that the number of elements in the tensor is less than the new view shape.
What exactly is data.size()?