Hello everybody, I am new to PyTorch. I have a problem when I tried to train my data. When I run my program there is an error like following:
Traceback (most recent call last):
File “/home/riza/Documents/D E F E C T D E T E C T I O N/code/GAN/WGAN.py”, line 140, in
dataloader = torch.utils.data.DataLoader(dataset, batch_size=opt.batch_size, shuffle=True, drop_last=True)
File “/usr/local/lib/python3.5/dist-packages/torch/utils/data/dataloader.py”, line 176, in init
sampler = RandomSampler(dataset)
File “/usr/local/lib/python3.5/dist-packages/torch/utils/data/sampler.py”, line 66, in init
“value, but got num_samples={}”.format(self.num_samples))
ValueError: num_samples should be a positive integer value, but got num_samples=0
import os
dirpath = os.getcwd()
print("current directory is : " + dirpath)
current directory is : /media/riza/EA62E27862E248C1/ubuntu_ppt/GAN_final/GAN/Defect/back/crack
That is I checked from my terminal, I directly open terminal from my dataset folder
Make sure the __len__ method of your Dataset returns a valid number of samples (>0).
How are you passing (or loading) the data and how are you calculating the length of the Dataset?