jvanvugt / pytorch-domain-adaptation

A collection of implementations of adversarial domain adaptation algorithms
MIT License
617 stars 108 forks source link

ValueError: a must be greater than 0 unless no samples are taken #7

Open magnum-zx opened 3 years ago

magnum-zx commented 3 years ago

Hello! guys. Has anyone ever encountered such mistakes? How the errors fix?

Traceback (most recent call last): File "wdgrl.py", line 134, in main(args) File "wdgrl.py", line 76, in main (source_x, source_y), (targetx, ) = next(batch_iterator) File "H:\anaconda3\envs\torch1.4\lib\site-packages\torch\utils\data\dataloader.py", line 517, in next data = self._next_data() File "H:\anaconda3\envs\torch1.4\lib\site-packages\torch\utils\data\dataloader.py", line 557, in _next_data data = self._dataset_fetcher.fetch(index) # may raise StopIteration File "H:\anaconda3\envs\torch1.4\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in fetch data = [self.dataset[idx] for idx in possibly_batched_index] File "H:\anaconda3\envs\torch1.4\lib\site-packages\torch\utils\data_utils\fetch.py", line 44, in data = [self.dataset[idx] for idx in possibly_batched_index] File "G:\pytorch-domain-adaptation\data.py", line 38, in getitem bsds_image = self._random_bsds_image() File "G:\pytorch-domain-adaptation\data.py", line 51, in _random_bsds_image i = self.rng.choice(len(self.bsds)) File "mtrand.pyx", line 902, in numpy.random.mtrand.RandomState.choice ValueError: a must be greater than 0 unless no samples are taken

Learn2Ln commented 3 years ago

The cause of the error is that you don't follow the first step of the "Instructions". If you download the BSDS500 dataset and extract it at the right folder, this error will not happen. Because you have to use the BSDS500 dataset to generate the images of MNISTM.