1_logistic_regression.py 文件源码

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

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


问题


面经


文章

微信
公众号

扫码关注公众号