def plot_100_images(X, indices=None):
"""Plot 100 randomly picked digits."""
width, height = IMAGE_WIDTH, IMAGE_HEIGHT
nrows, ncols = 10, 10
if indices is None:
indices = range(X.shape[0])
indices_to_display = np.random.choice(indices, nrows * ncols)
big_picture = np.zeros((height * nrows, width * ncols))
irow, icol = 0, 0
for idx in indices_to_display:
if icol == ncols:
irow += 1
icol = 0
iimg = X[idx].reshape(width, height).T # transpose the data set
big_picture[irow * height:irow * height + iimg.shape[0], icol * width:icol * width + iimg.shape[1]] = iimg
icol += 1
img = misc.toimage(big_picture)
plt.imshow(img, cmap=matplotlib.cm.Greys_r)
plt.show()
1_nn_training_example.py 文件源码
python
阅读 27
收藏 0
点赞 0
评论 0
评论列表
文章目录