资源简介
MNIST数据库处理-matlab生成mnist_uint8.mat。
功能:将下载得到的二进制文件转换为10进制数据,提取像素数据和标签数据
适用:仅适用于MNIST数据集,修改后可适用于其他
功能:将下载得到的二进制文件转换为10进制数据,提取像素数据和标签数据
适用:仅适用于MNIST数据集,修改后可适用于其他

代码片段和文件信息
%MNIST源文件下载地址http://yann.lecun.com/exdb/mnist/index.html
%功能:将下载得到的二进制文件转换为10进制数据,提取像素数据和标签数据
%适用:仅适用于MNIST数据集,修改后可适用于其他
%Create by VivienFu e-mail:vivienfu@163.com
function output=decodefile(filenametype)
%数据介绍如下,参考网址http://yann.lecun.com/exdb/mnist/index.html
% TRAINING SET LABEL FILE (train-labels-idx1-ubyte):
%
% [offset] [type] [value] [description]
% 0000 32 bit integer 0x00000801(2049) magic number (MSB first)
% 0004 32 bit integer 60000 number of items
% 0008 unsigned byte ?? label
% 0009 unsigned byte ?? label
% ........
% xxxx unsigned byte ?? label
% The labels values are 0 to 9.
% TRAINING SET IMAGE FILE (train-images-idx3-ubyte):
%
% [offset] [type] [value] [description]
% 0000 32 bit integer 0x00000803(2051) magic number
% 0004 32 bit integer 60000 number of images
% 0008 32 bit integer 28 number of rows
% 0012 32 bit integer 28 number of columns
% 0016 unsigned byte ?? pixel
% 0017 unsigned byte ?? pixel
% ........
% xxxx unsigned byte ?? pixel
% TEST SET LABEL FILE (t10k-labels-idx1-ubyte):
%
% [offset] [type] [value] [description]
% 0000 32 bit integer 0x00000801(2049) magic number (MSB first)
% 0004 32 bit integer 10000 number of items
% 0008 unsigned byte ?? label
% 0009 unsigned byte ?? label
% ........
% xxxx unsigned byte ?? label
% The labels values are 0 to 9.
%
% TEST SET IMAGE FILE (t10k-images-idx3-ubyte):
%
% [offset] [type] [value] [description]
% 0000 32 bit integer 0x00000803(2051) magic number
% 0004 32 bit integer 10000 number of images
% 0008 32 bit integer 28 number of rows
% 0012 32 bit integer 28 number of columns
% 0016 unsigned byte ?? pixel
% 0017 unsigned byte ?? pixel
% ........
% xxxx unsigned byte ?? pixel
fio=fopen(filename‘r‘);%原始文件中数据是以2进制存储的。
a = fread(fio‘uint8‘);%以8进制方式读取源文件。虽然前几项是32bit的,但是图像像素数据是8bit的,所以此处用8bit处理。
if strcmp(type‘image‘)
% magic_num=a(1)*256^3+a(2)*256^2+a(3)*256+a(4);
% image_num=a(5)*256^3+a(6)*256^2+a(7)*256+a(8);
% image_rows=a(9)*256^3+a(10)*256^2+a(11)*256+a(12);%默认训练和测试图像都已经reshape到一个size
% image_cols=a(13)*256^3+a(14)*256^2+a(15)*256+a(16);
output=a(17:end);%提取像素数据
else if strcmp(type‘label‘)
% magic_num=a(1)*256^3+a(2)*256^2+a(3)*256+a(4);
% image_num=a(5)*256^3+a(6)*256^2+a(7)*256+a(8);
output=a(9:end);
end
end
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2019-12-29 13:43 MNIST to uint8 by matlab\
文件 3011 2017-01-01 22:41 MNIST to uint8 by matlab\decodefile.m
文件 1275 2017-01-01 22:41 MNIST to uint8 by matlab\mnist_uint8.m
相关资源
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
- 通过不同方法进行粗糙集属性约简m
评论
共有 条评论