you are right, the function has no problem because I tried with the train_set so the problem is from the val_set.
but I don’t know what is wrong in the data.
can you explain what is wrong from the code:
TEXT = data.Field(batch_first=True, include_lengths=True)
LABEL = data.LabelField(dtype=torch.float, batch_first=True)
feilds = [('text', TEXT), ('label', LABEL)]

train, val = data.TabularDataset(path='processed_data.csv', format='csv', fields=feilds, skip_header=True).split()

TEXT.build_vocab(train, min_freq=5, vectors='glove.twitter.27B.50d')
LABEL.build_vocab(train)

train_set, val_set = data.BucketIterator.splits((train, val), batch_sizes=(32, 32), sort_within_batch=True,
                                                device='cpu', sort_key=lambda x: len(x.text))

but I think it’s from the processing phase because the code is good in my opinion.
what do you think?