将mnist数据集保存为可见图片
#下载mnist数据集
from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf mnist = input_data.read_data_sets("/Users/dudu/Desktop/project/img",one_hot=True)
#保存为图片
import scipy.misc import os save_dir = '/Users/dudu/Desktop/project/img/raw' if os.path.exists(save_dir) is False: os.makedirs(save_dir) for i in range(20): image = mnist.train.images[i,:] image = image.reshape(28,28) file = save_dir+'mnist_train_%d.jpg' % i scipy.misc.toimage(image,cmin=0.0,cmax=1.0).save(file)