为什么numpy数组不可写?

来源:4-5 利用神经网络解决分类和回归问题(3)

KingCoder

2021-08-07

train_data = dataset.MNIST(root=“mnist”,
train=True,
transform=transforms.ToTensor(),
download=True)

D:\anaconda3\envs\AI\python.exe E:/PycharmProjects/handwrittenNumeralRecognition/demo_cls.py
D:\anaconda3\envs\AI\lib\site-packages\torchvision\datasets\mnist.py:498: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at …\torch\csrc\utils\tensor_numpy.cpp:180.)
return torch.from_numpy(parsed.astype(m[2], copy=False)).view(*s)

数据集下载完了,提示numpy不可写,MNIST文件夹只有row,为什么?图片描述图片描述
就是刚开始加载数据的时候报错

写回答

1回答

会写代码的好厨师

2021-08-09

代码截图,多截取一些。

0
3
KingCoder
回复
会写代码的好厨师
嗯,可以正常运行的,就是不太理解这个警告为什么
2021-08-09
共3条回复

PyTorch入门到进阶 实战计算机视觉与自然语言处理项目

理论基础+技术讲解+实战开发,快速掌握PyTorch框架

1190 学习 · 293 问题

查看课程