当前位置:网站首页>解决dataset.mnist无法加载进去的情况
解决dataset.mnist无法加载进去的情况
2022-08-04 15:11:00 【看星河的兔子】
在正常输入代码时,有无法加载入这个模块的问题。
我在CSDN上找了很久没有具体的解决办法,后面我根据《深度学习入门:基于python的理论和实现》样例代码才找到解决方法。
OK首先,进入网址下载文件
图灵
点击随书下载
下载中间的源代码。
再为导入父目录中的文件进行设定
将dataset文件放入你工程文件的目录下
import sys, os
sys.path.append(os.pardir)
from dataset.mnist import load_mnist
(x_train,t_train),(x_test,t_test)=load_mnist(flatten=True,normalize=False)
print(x_train.shape)
print(t_train.shape)
print(t_test.shape)
print(x_test.shape)
可以看到现在已经没有错误提示了。第一次调用load_mnist函数时,需要接入网络,第二次之后调用读入pickle文件即可。
##显示MNIST图像
import sys, os
sys.path.append(os.pardir)
import numpy as np
from PIL import Image
from dataset.mnist import load_mnist
def img_show(img):
pil_img=Image.fromarray(np.uint8(img)) #array转换成image
pil_img.show()
(x_train,t_train),(x_test,t_test)=load_mnist(flatten=True,normalize=False)
img=x_train[0]
label=t_train[0]
print(label)
print(img.shape)
img_show(img)
img=img.reshape(28,28)
print(img.shape)
img_show(img)
边栏推荐
- AOSP built-in APP franchise rights white list
- leetcode: 251. Expanding 2D Vectors
- 什么是 DevOps?看这一篇就够了!
- 卖家寄卖流程梳理
- 【历史上的今天】8 月 4 日:第一位图灵奖女性得主;NVIDIA 收购 MediaQ;首届网络安全挑战大赛完成
- Online Excel based on Next.js
- Redis 高可用
- leetcode:254. 因子的组合
- Zheng Qing freshmen school competition and middle-aged engineering selection competition
- C端折戟,转战B端,联想的元宇宙梦能成吗?
猜你喜欢
随机推荐
C端折戟,转战B端,联想的元宇宙梦能成吗?
洛谷题解P4326 求圆的面积
【北亚数据恢复】IBM System Storage存储lvm信息丢失数据恢复方案
leetcode:259. 较小的三数之和
Legal education combined with VR panorama, intuitively feel and learn the spirit of the rule of law
C语言写简单三子棋
输入输出流总结
leetcode: 259. Smaller sum of three numbers
Next -18- 添加代码复制按钮
明明加了唯一索引,为什么还是产生重复数据?
宣传海报
Win10无法访问移动硬盘怎么解决
leetcode: 250. Count subtrees of equal value
2022杭电多校3
7 天能找到 Go 工作吗?学学 Go 数组和指针试试
如何和程序员谈恋爱
Next -21- 添加相册系列 - 1- 框架设置
leetcode:215无序数组中找第k大的元素
1401 - Web technology 】 【 introduction to graphical Canvas
什么是 DevOps?看这一篇就够了!









