I’m running a code that uses dataloader.dataset. The original code is designed to run on Pytorch 1.1, but my Pytorch version is higher. Are there any alternatives to this attribute?
And here’s the error report. AttributeError: '_SingleProcessDataLoaderIter' object has no attribute 'dataset'
The posted code snippet it not accessing the .dataset attribute so I’m unsure how this error can even be raised.
The tutorial works fine for me, so please post a minimal, executable code snippet to reproduce the issue.
I doubt it, as I’m also using a (quite new) source build, so please feel free to point to the line of code in the tutorial creating the issue (I cannot reproduce it) or post a code snippet which would raise the error.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~\AppData\Local\Temp\ipykernel_9516\372505004.py in <module>
1 dataiter = iter(data_loader)
----> 2 images, labels = next(dataiter)
3 print(torch.min(images), torch.max(images))
~\anaconda3\lib\site-packages\torch\utils\data\dataloader.py in __next__(self)
626 # TODO(https://github.com/pytorch/pytorch/issues/76750)
627 self._reset() # type: ignore[call-arg]
--> 628 data = self._next_data()
629 self._num_yielded += 1
630 if self._dataset_kind == _DatasetKind.Iterable and \
~\anaconda3\lib\site-packages\torch\utils\data\dataloader.py in _next_data(self)
669 def _next_data(self):
670 index = self._next_index() # may raise StopIteration
--> 671 data = self._dataset_fetcher.fetch(index) # may raise StopIteration
672 if self._pin_memory:
673 data = _utils.pin_memory.pin_memory(data, self._pin_memory_device)
~\anaconda3\lib\site-packages\torch\utils\data\_utils\fetch.py in fetch(self, possibly_batched_index)
56 data = self.dataset.__getitems__(possibly_batched_index)
57 else:
---> 58 data = [self.dataset[idx] for idx in possibly_batched_index]
59 else:
60 data = self.dataset[possibly_batched_index]
~\anaconda3\lib\site-packages\torch\utils\data\_utils\fetch.py in <listcomp>(.0)
56 data = self.dataset.__getitems__(possibly_batched_index)
57 else:
---> 58 data = [self.dataset[idx] for idx in possibly_batched_index]
59 else:
60 data = self.dataset[possibly_batched_index]
~\anaconda3\lib\site-packages\torchvision\datasets\mnist.py in __getitem__(self, index)
143
144 if self.transform is not None:
--> 145 img = self.transform(img)
146
147 if self.target_transform is not None:
TypeError: 'bool' object is not callable