Yes, I think the slicing operation could create an unexpected shape.
The posted line of code sliced the frame in two dimensions using the specified start and end indices.
As described before, check which shape the training images had and make sure the new images have the same.