MNIST 数据集可视化代码

来源:互联网 发布:navicat linux 破解 编辑:程序博客网 时间:2024/05/15 05:09


写一个matlab小程序将mnist数据集可视化,将以下代码命名为image_visualization 并放在 $caffe_root/data/mnist/  下,{独立运行,不必编译caffe,但是要提前Linux下下载数据}



clear;clc;clear all;image_file_name='t10k-images-idx3-ubyte';index_filename='t10k-labels-idx1-ubyte';fid1=fopen(image_file_name,'rb');fid2=fopen(index_filename,'rb');images_data=fread(fid1,'uint8');index_data=fread(fid2,'uint8');fclose(fid1);fclose(fid2);images_data=images_data(17:end);index_data=index_data(9:end);image_buffer=zeros(28,28);for k=1:144:length(images_data)/28/28    figure(144);    for t=1:144        image_buffer=reshape(images_data((k+t-2)*28*28+1:(k+t-1)*28*28),28,28);        subplot(12,12,t);        imshow(uint8(image_buffer)');        title(num2str(index_data(k+t-1)));    end    pause;end

结果如图(100个数,源码是144个数,未贴出)


0 0
原创粉丝点击