Issue
I'm working on MNIST datasets using Pytorch and I'm trying to scale the images, I ran into problems associated with Numpy
train_dataset = datasets.MNIST(root='data',
train=True,
transform=transforms.ToTensor(),
download=True)
And here's my error, really confused on how to solve this
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-5-ef2899ce3492> in <module>
6 train=True,
7 transform=transforms.ToTensor(),
----> 8 download=True)
9
10 test_dataset = datasets.MNIST(root='data',
~\miniconda3\envs\6.86x\lib\site-packages\torchvision\datasets\mnist.py in __init__(self, root, train, transform, target_transform, download)
91 ' You can use download=True to download it')
92
---> 93 self.data, self.targets = self._load_data()
94
95 def _check_legacy_exist(self):
~\miniconda3\envs\6.86x\lib\site-packages\torchvision\datasets\mnist.py in _load_data(self)
110 def _load_data(self):
111 image_file = f"{'train' if self.train else 't10k'}-images-idx3-ubyte"
--> 112 data = read_image_file(os.path.join(self.raw_folder, image_file))
113
114 label_file = f"{'train' if self.train else 't10k'}-labels-idx1-ubyte"
~\miniconda3\envs\6.86x\lib\site-packages\torchvision\datasets\mnist.py in read_image_file(path)
507
508 def read_image_file(path: str) -> torch.Tensor:
--> 509 x = read_sn3_pascalvincent_tensor(path, strict=False)
510 assert(x.dtype == torch.uint8)
511 assert(x.ndimension() == 3)
~\miniconda3\envs\6.86x\lib\site-packages\torchvision\datasets\mnist.py in read_sn3_pascalvincent_tensor(path, strict)
496 parsed = np.frombuffer(data, dtype=m[1], offset=(4 * (nd + 1)))
497 assert parsed.shape[0] == np.prod(s) or not strict
--> 498 return torch.from_numpy(parsed.astype(m[2])).view(*s)
499
500
RuntimeError: Numpy is not available
Solution
Figured it out, my Numpy version was outdated compared to pytorch. Updated it basically!
Answered By - Muhammad Bello
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.