1_nn_training_example.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:Machine-Learning-Coursera-Tensorflow 作者: themech 项目源码 文件源码
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()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号