I’m running into trouble when trying to load the Fashion MNIST data set for section 4.2 of the reading (Spyder IDE, MacOS).
My code thus far:
When I attempt to run, my console reads:
runfile(’/Users/myname/ClassficationData.py’, wdir=’/Users/myname’)
Traceback (most recent call last):
File “/Users/myname/opt/anaconda3/envs/spyder-env/lib/python3.9/site-packages/spyder_kernels/py3compat.py”, line 356, in compat_exec
exec(code, globals, locals)
File “/Users/myname/ClassficationData.py”, line 32, in
data = FashionMNIST(resize=(32, 32))
File “/Users/myname/ClassficationData.py”, line 25, in init
self.train = torchvision.datasets.FashionMNIST(
File “/Users/myname/opt/anaconda3/envs/spyder-env/lib/python3.9/site-packages/torchvision/datasets/mnist.py”, line 87, in init
self.download()
File “/Users/myname/opt/anaconda3/envs/spyder-env/lib/python3.9/site-packages/torchvision/datasets/mnist.py”, line 168, in download
os.makedirs(self.raw_folder, exist_ok=True)
File “/Users/myname/opt/anaconda3/envs/spyder-env/lib/python3.9/os.py”, line 215, in makedirs
makedirs(head, exist_ok=exist_ok)
File “/Users/myname/opt/anaconda3/envs/spyder-env/lib/python3.9/os.py”, line 215, in makedirs
makedirs(head, exist_ok=exist_ok)
File “/Users/myname/opt/anaconda3/envs/spyder-env/lib/python3.9/os.py”, line 225, in makedirs
** mkdir(name, mode)**
PermissionError: [Errno 13] Permission denied: '…/data’
It seems that there is a permission error when attempting to make the data file. I’m not sure where …/data is located, however. My current project file, along with the d2l DataModule parent class files are under /Users/myname.
class DataModule(d2l.HyperParameters):
“”“Defined in :numref:sec_oo-design
”""
def init(self, root=’…/data’, num_workers=4):
self.save_hyperparameters()
def get_dataloader(self, train):
raise NotImplementedError
def train_dataloader(self):
return self.get_dataloader(train=True)
def val_dataloader(self):
return self.get_dataloader(train=False)
def get_tensorloader(self, tensors, train, indices=slice(0, None)):
"""Defined in :numref:`sec_synthetic-regression-data`"""
tensors = tuple(a[indices] for a in tensors)
dataset = torch.utils.data.TensorDataset(*tensors)
return torch.utils.data.DataLoader(dataset, self.batch_size,
shuffle=train)
I’ve attempted to use PyTorch’s walkthrough for the same data set, and I can load in the data fine without creating the FashionMNIST child class:
training_data = datasets.FashionMNIST(
root=“data”,
train=True,
download=True,
transform=ToTensor()
)
test_data = datasets.FashionMNIST(
root=“data”,
train=False,
download=True,
transform=ToTensor()
)
Sorry for the confusion. I’m new to d2l and python all together. How can I get this to properly download with an instance of FashionMNIST?