Cannot iterate through a DataLoader object

Hello, I have the ucf 101 dataset loaded as follows:

dataComplete = torchvision.datasets.UCF101('directory', frames_per_clip=16, step_between_clips=1, frame_rate=None, fold=1, train=True, transform=transformF, _precomputed_metadata=None, num_workers=1, _video_width=0, _video_height=0, _video_min_dimension=0, _audio_samples=0)
data =, batch_size=3, shuffle=True)
#where transformF = transforms.ToTensor()

and I am trying to access the tensors stored in the dataLoader object, but everytime I try to execute:

for n_batch in data:

I get the error

TypeError: pic should be PIL Image or ndarray. Got <class 'torch.Tensor'>

I tried using dataComplete instead and using enumerate(), range() ecc. but it shows the same error

Error says it needs PIL but you passed tensor.

You are converting a tensor to tensor using ToTensor which only accepts PIL images.
Remove that line.

In the docs of UCF101 it says it returns a tensor.


Thanks for your reply, understood, but now I keep getting the error

RuntimeError: stack expects each tensor to be equal size, but got [1, 0] at entry 0 and [2, 18432] at entry 1