当前位置:网站首页>解决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)
边栏推荐
猜你喜欢
随机推荐
全球电子产品需求放缓,三星手机越南工厂每周只需要干 3~4 天
如何优雅的消除系统重复代码?
杭电校赛(逆袭指数)
【历史上的今天】8 月 4 日:第一位图灵奖女性得主;NVIDIA 收购 MediaQ;首届网络安全挑战大赛完成
Bluetooth Technology|In the first half of the year, 1.3 million charging piles were added nationwide, and Bluetooth charging piles will become the mainstream of the market
This week to discuss the user experience: Daedalus Nemo to join Ambire, explore the encryption of the ocean
大众点评搜索相关性技术探索与实践
C# SolidWorks二次开发---工程图简单版标注孔信息
leetcode:254. 因子的组合
2022杭电多校3
Taurus.MVC WebAPI 入门开发教程2:添加控制器输出Hello World。
Next -20- 使用自定义样式 (custom style)
AOSP内置APP特许权限白名单
Redis-哨兵模式
郑轻新生校赛和中工选拔赛题解
Hangzhou Electric School Competition (Counter Attack Index)
你以为在做的是微服务?不!你做的只是分布式单体!
tif转mat
IP第十八天笔记
Oracle 数据库用户创建、重启、导入导出








