We had recently a similar discussion in this topic.
The DataLoader
might take inputs, where __getitem__
and __len__
is defined.
E.g. this code will work:
x = [0, 1, 2]
print(x.__getitem__)
print(x.__len__)
loader = DataLoader(x)
for data in loader:
print(data)
However, I would still recommend to derive your custom dataset from Dataset
and pass it to the DataLoader
, as this will give you more control of how __getitem__
and __len__
is implemented.