yunjey / pytorch-tutorial

PyTorch Tutorial for Deep Learning Researchers
MIT License
29.79k stars 8.03k forks source link

a question about dataloader #154

Open ShellingFord221 opened 5 years ago

ShellingFord221 commented 5 years ago

Hi If I don't want to test the model in batch (i.e. test the test data one by one), should my code be:

test_loader = torch.utils.data.DataLoader(dataset=test_dataset,
                                      batch_size=batch_size,                             # this line still remains
                                      shuffle=False)
...
for images, labels in test_loader:        # not for batch_idx, (images, labels) in enumerate(test_loader):
...

And other codes don't change. Am I correct? Thanks!

weixia1 commented 5 years ago

u can set batch_size =1 ,if you want test the data one by one batch_size = 1 test_loader = torch.utils.data.DataLoader(dataset=test_dataset, batch_size=batch_size, # this line still remains shuffle=False)