I am using torch.utils.data.DataLoader. like train_features, train_labels = next(iter(train_dataloader))
I want to determine which index the trainer is chosen?
for batch_idx, data in enumerate(trainloader, 0):
can index from 0, but if we shuffle, can we know the indices for this batch?
You could return the passed index
from the Dataset.__getitem__
method and use it in your DataLoader
loop.
Hello,
In :
https://pytorch.org/tutorials/beginner/basics/data_tutorial.html
when using:
train_features, train_labels = next(iter(train_dataloader))
I believe that train_features takes the values from train_dataloader.data and train_labels takes the values from train_dataloader.targets. However, the class has several other tensors. How do I know which tensor is actually being caught, and why is this tensor being caught instead of the others?
The Dataset.__getitem__
method is responsible for the loading and processing of the samples and will return these. The DataLoader
will just batch these. If you want to check which tensors are processed in which way, check the Dataset
implementation.