I created a custom dataset in pytorch. Implemented getitem where I’m reading from a csv file. csv file contains paths to folders which contain video frames. So, one folder contains frames for one video. I read 16 frames from any such folder and create a [3,16,112,112] tensor. Problem is that for my train_loader I had to use unsqueeze(0) for adding one extra dimension to make this tensor look like [1,3,16,112,112] to work with C3D feature extractor (implemented in pytorch) while for my validation set, this same custom dataset already starts giving [N,3,16,112,112] which ultimately results in [1,N,3,16,112,112] hence gives an error saying ValueError: Expected 5D tensor as input, got 6D tensor instead. So dataset is behaving in two different ways.