You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When iterating on a DataLoader object I get TypeError: __array__() takes 1 positional argument but 2 were given.
It seems that there is problem with the fetch procedure that retrieve the next item from the DataLoader element.
It seems also that it's an error present only in the 0.10.0 version.
Passing to a previous version, 0.9.1 in my case, the problem disappers.
To Reproduce
Steps to reproduce the behavior:
Create any DataLoader
Iterate on it
Here a code snippet:
import torchvision
import torchvision.transforms as transforms
from torch.utils.data import DataLoader
batch_size = 64
transform = transforms.Compose([
transforms.Resize((32, 32)),
transforms.ToTensor(),
])
trainset = torchvision.datasets.MNIST(
root='../dataset', train=True, download=True, transform=transform
)
trainloader = DataLoader(
trainset, batch_size=batch_size, shuffle=True
)
for idx, data in enumerate(trainloader):
print(idx)
Here the StackTrace I get:
Traceback (most recent call last):
File "../src/test.py", line 18, in <module>
for idx, data in enumerate(trainloader):
File ..\venv\lib\site-packages\torch\utils\data\dataloader.py", line 521, in __next__
data = self._next_data()
File "..\venv\lib\site-packages\torch\utils\data\dataloader.py", line 561, in _next_data
data = self._dataset_fetcher.fetch(index) # may raise StopIteration
File "..\venv\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in fetch
data = [self.dataset[idx] for idx in possibly_batched_index]
File "..\venv\lib\site-packages\torch\utils\data\_utils\fetch.py", line 44, in <listcomp>
data = [self.dataset[idx] for idx in possibly_batched_index]
File "..\venv\lib\site-packages\torchvision\datasets\mnist.py", line 134, in __getitem__
img = self.transform(img)
File "..\venv\lib\site-packages\torchvision\transforms\transforms.py", line 60, in __call__
img = t(img)
File "..\venv\lib\site-packages\torchvision\transforms\transforms.py", line 97, in __call__
return F.to_tensor(pic)
File "..\venv\lib\site-packages\torchvision\transforms\functional.py", line 129, in to_tensor
np.array(pic, mode_to_nptype.get(pic.mode, np.uint8), copy=True)
TypeError: __array__() takes 1 positional argument but 2 were given
Expected behavior
The execution of the iteration on the DataLoader
Environment
PyTorch / torchvision Version: 1.9.0 / 0.10.0
OS: Windows 10
How you installed PyTorch / torchvision (conda, pip, source): pip
Python version: 3.7.0
CUDA/cuDNN version: No CUDA
GPU models and configuration: No CUDA
The text was updated successfully, but these errors were encountered:
馃悰 Bug
When iterating on a DataLoader object I get
TypeError: __array__() takes 1 positional argument but 2 were given
.It seems that there is problem with the fetch procedure that retrieve the next item from the DataLoader element.
It seems also that it's an error present only in the
0.10.0
version.Passing to a previous version,
0.9.1
in my case, the problem disappers.To Reproduce
Steps to reproduce the behavior:
Here a code snippet:
Here the StackTrace I get:
Expected behavior
The execution of the iteration on the DataLoader
Environment
conda
,pip
, source):pip
The text was updated successfully, but these errors were encountered: