ConcatDataset Error: AttributeError: 'numpy.ndarray' object has no attribute 'numel'

.numel() is defined for PyTorch tensors, not numpy arrays. Based on your error message it seems that you are using numpy arrays inside your Dataset, which then fails in:

numel = sum([x.numel() for x in batch])

Assuming the __getitem__ returns these numpy arrays (I don’t have a clue which types these objects have), conert them to tensors via tensor = torch.from_numpy(array).

2 Likes