Expected 5D Tensor Got 6D Tensor

Hi,

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.

Then don’t unsqueeze and use N as your batch size, no ?

Point is that why my dataset class is behaving in two different ways. When loader wants a batch of size 8, it should automatically create a batch of size 8, ain’t it? Why I need to use unsqueeze in the first place?

the input of your network should be 5D, first dimension is the size of your batch, second the dimension of data and last 3 related to the 3D data. So I don’t see why you unsqueeze in the first place if you already have 5 dimensions.

@singlepoint Hi,
Which C3D implementation are you using? Can you provide the link?