当前位置:网站首页>解决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)
边栏推荐
- 基于数据库实现分布式锁
- 分布式链路追踪Jaeger + 微服务Pig在Rainbond上的实践分享
- LeetCode_模拟_中等_498.对角线遍历
- Http-Sumggling缓存漏洞分析
- 郑轻新生校赛和中工选拔赛题解
- C# SolidWorks二次开发---工程图简单版标注孔信息
- Leetcode: 215 disorderly to find the first big k element in the array
- 明明加了唯一索引,为什么还是产生重复数据?
- C# 将dll打包到程序中
- 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
猜你喜欢
随机推荐
技术分享| 小程序实现音视频通话
Why, when you added a unique index or create duplicate data?
我爱七夕哈哈哈
全球电子产品需求放缓,三星手机越南工厂每周只需要干 3~4 天
【Harmony OS】【FAQ】Hongmeng Questions Collection 2
性能提升400倍丨外汇掉期估值计算优化案例
Hangzhou Electric School Competition (Counter Attack Index)
LeetCode_模拟_中等_498.对角线遍历
Roslyn 通过 nuget 统一管理信息
AOSP built-in APP franchise rights white list
输入输出流总结
MVCC实现过程
How to fall in love with a programmer
明明加了唯一索引,为什么还是产生重复数据?
Leetcode: 215 disorderly to find the first big k element in the array
基于 Next.js实现在线Excel
C端折戟,转战B端,联想的元宇宙梦能成吗?
洛谷题解P1028 数的计算
如何和程序员谈恋爱
JCMsuite Application: Oblique Plane Wave Propagation Transmission Through Aperture