当前位置:网站首页>mnist有多少张图片(怎么读取图片文字)
mnist有多少张图片(怎么读取图片文字)
2022-07-29 18:52:00 【全栈程序员站长】
大家好,又见面了,我是你们的朋友全栈君。
记录用不同的方法读取Mnist数据集
1、Python的PIL模块读取Mnist图片
#读取文件夹mnist下的60000张图片,图片为灰度图,所以为1通道,如果是将彩色图作为输入,则将1替换为3,图像大小28*28
def load_data():
data = np.empty((60000,1,28,28),dtype="float32")
label = np.empty((60000,),dtype="uint8")
imgs = os.listdir("E:\\DataSet\\mnist")
num = len(imgs)
for i in range(num):
img = Image.open("E:\\DataSet\\mnist\\"+imgs[i])
arr = np.asarray(img,dtype="float32")
data[i,:,:,:] = arr
label[i] = int(imgs[i].split('.')[0])
#归一化和零均值化
data /= np.max(data)
data -= np.mean(data)
return data,label
if __name__ == '__main__':
load_data()2、keras自带的 load_data( ) 方法
from keras.datasets import mnist
(X_train, y_train), (X_test, y_test) = mnist.load_data()X_train.shape (60000, 28, 28),X_test.shape (10000, 28, 28); y_train.shape (60000,),y_test.shape (10000,)。
这个方法未进行归一化,像素点数据范围是0-255。
参考:
http://keras-cn.readthedocs.io/en/latest/other/datasets/
https://github.com/wepe/MachineLearning/
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/129521.html原文链接:https://javaforall.cn
边栏推荐
- R语言使用zoo包表示时间序列数据(time series data)
- First-line big factory software test interview questions and answer analysis, the strongest version of 2022...
- Make a file upload progress bar
- 搭建自己的以图搜图系统 (一):10 行代码以图搜图
- 【盘古Coder】:高性能函数级程序语言生成模型
- 成都 | 转行软件测试,从零收入到月薪过万,人生迎来新转折...
- 要卖课、要带货,知识付费系统帮你一步搞定!
- 每日优鲜“坠落”,生鲜前置仓的面子和里子
- H264码流RTP封装方式详解
- 本科毕业六年,疫情期间备战一个月,四面阿里巴巴定级P7
猜你喜欢
随机推荐
H265码流RTP封装方式详解
【中标麒麟系统Your trial is EXPIRED and no VALID licens 关闭弹窗】
开源数据标注工具
2.1寸旋钮屏结合6.86寸串口屏助力集成灶智能升级|启明智显
小程序组件的总结
实现一个可调节大小的 Switch 开关
嵌入式开发:嵌入式基础——软件错误分类
第02章 MySQL的数据目录【1.MySQL架构篇】【MySQL高级】
2.5w字 + 36 张图爆肝操作系统面试题 学不吐你
Experience Sharing | Tips for Writing Easy-to-Use Online Product Manuals
不堆概念、换个角度聊多线程并发编程
R语言使用xts包表示时间序列数据(time series data)
R语言时间序列数据提取:使用xts包的first函数提取时间序列中最前面10天的数据(first 10 day)
H264码流RTP封装方式详解
优雅实现经典的生产者消费者模式
c语言 || 杂
First-line big factory software test interview questions and answer analysis, the strongest version of 2022...
如何防止订单重复支付?
Typescript使用修饰器混合方法到类
搭建自己的以图搜图系统 (一):10 行代码以图搜图









