Search code examples
pythontorch

What is the other parameter returned by DataLoader.dataset.samples[i]


I'm using the torch.utils.data.DataLoader to lookup the filename in an iterable-style dataset. When calling DataLoader.dataset.samples[i] within an the iterative loop, I get the filename and an integer. Example:

('car.JPEG', 0)

What does the second parameter stand for?


Solution

  • The DataLoader returns each member of the dataset object which is a tuple containing the sample and the class_index it belongs to. So in your case, the first index of the tuple contains the sample (car.JEPG) and the second index is the class_index that the sample belongs to (0 in your case). To learn more go through the docs.