July 2018
Intermediate to advanced
474 pages
13h 37m
English
This section walks through the steps to convert a sample of MNIST arrays to files in a local folder.
if not os.path.exists('MNIST/images'): os.makedirs('MNIST/images/')os.chdir('MNIST/images/')
from matplotlib import imagefor i in range(1,10): png = data.train.images[i] png = np.array(png, dtype='float') pixels = png.reshape((28, 28)) image.imsave('image_no_{}.png'.format(i), pixels, cmap = 'gray')
print(os.listdir())
Read now
Unlock full access