Dataloader size must match?


I am using a dataloader with IMDB dataset and i get this error :

RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0. Got 1 and 2 in dimension 1 at …\aten\src\TH/generic/THTensor.cpp:711

class DataProcessing(Dataset):
def init(self,data,labels,tokenizer): = data
self.tokenizer = tokenizer
self.labels = labels
def getitem(self, index):
return torch.tensor(self.tokenizer.encode([index,:].item()[:3]))
def len(self):

train_sampler = RandomSampler(dp)
train_dataloader = DataLoader(dp, sampler=train_sampler, batch_size=100)

i reduced the size and now it’s always the same but i still get the error ?