当前位置:网站首页>解决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)
边栏推荐
- This week to discuss the user experience: Daedalus Nemo to join Ambire, explore the encryption of the ocean
- 技术分享| 融合调度系统中的电子围栏功能说明
- Oracle 数据库用户创建、重启、导入导出
- 杭电校赛(ACM组队安排)
- Cisco-小型网络拓扑(DNS、DHCP、网站服务器、无线路由器)
- eNSP-小型网络拓扑(DNS、DHCP、网站服务器、无线路由器)
- 【Web技术】1401- 图解 Canvas 入门
- 杭电校赛(逆袭指数)
- OAID是什么
- CloudCompare&PCL 点云按网格划分(点云分幅)
猜你喜欢
随机推荐
饿了么智能头盔专利获授权,进一步提升骑手安全保障
CloudCompare&PCL 点云按网格划分(点云分幅)
宣传海报
2022 Hangzhou Electric Multi-School 4
技术分享| 融合调度系统中的电子围栏功能说明
Roslyn 通过 nuget 统一管理信息
leetcode: 251. Expanding 2D Vectors
X-ray grazing incidence focusing mirror
2022杭电多校3
Jupyter常用操作总结(强烈建议收藏,持续更新实用操作)
leetcode:250. 统计同值子树
Online Excel based on Next.js
C# 谁改了我的代码
Nuget 通过 dotnet 命令行发布
MySQL优化学习笔记
Codeforces Round #811 A~F
什么是 DevOps?看这一篇就够了!
小程序|炎炎夏日、清爽一夏、头像大换装
Google plug-in. Download contents file is automatically deleted after solution
JCMsuite Application: Oblique Plane Wave Propagation Transmission Through Aperture








