def plot_100_images(X):
"""Plot 100 randomly picked digits."""
width, height = 20, 20
nrows, ncols = 10, 10
indices_to_display = np.random.choice(range(X.shape[0]), 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
fig = plt.figure(figsize=(6, 6))
img = misc.toimage(big_picture)
plt.imshow(img, cmap=matplotlib.cm.Greys_r)
plt.show()
1_logistic_regression.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录