【问题标题】:showing mnist digits using python, numpy and matplot使用 python、numpy 和 matplotlib 显示 mnist 数字
【发布时间】:2020-08-22 13:34:56
【问题描述】:

假设我在变量 L 中有 MNIST 数字。

L[0].reshape(28,28) 会给我机会用 matplot 来绘制: plt.matshow(L[0].reshape(28,28)).

但是,如果我想在 5x5 网格中绘制 25 位数字,我无法弄清楚如何随机播放 L[0:24] 以使用 matplot 正确绘制它。

也许任何人都知道该怎么做。

【问题讨论】:

    标签: python numpy matplotlib mnist


    【解决方案1】:

    一种方法是这样的:

    fig, axes = plt.subplots(5,5)
    for i, ax in enumerate(axes.ravel()):
        ax.imshow(L[i].reshape(28,28))
    

    这样你就可以遍历你的子图。 如果你想改变你的地块的顺序,你可以使用np.random.permutation(25) 这将改变你的索引:

    fig, axes = plt.subplots(5,5)
    for i, ax in zip(np.random.permutation(25), axes.ravel()):
        ax.imshow(L[i].reshape(28,28))
    

    【讨论】:

    • 顺便说一句 - 有没有可能在一个由许多单独的子图组成的子图上放置许多字母?
    • 不客气!欢迎接受并支持我的回答。
    • 你的意思是像一个副情节?你可以创建更多的子图吗?那会有帮助吗?你到底想展示什么?
    猜你喜欢
    • 2017-07-10
    • 2018-09-22
    • 2014-07-17
    • 1970-01-01
    • 1970-01-01
    • 2014-11-06
    • 2020-03-18
    • 2016-06-06
    • 2020-11-08
    相关资源
    最近更新 更多