【问题标题】:cannot reshape array of size 64 into shape (28,28)无法将大小为 64 的数组重塑为形状 (28,28)
【发布时间】:2019-08-23 01:36:48
【问题描述】:

无法使用 sklean 重塑 mnist 数据集中的图像 这是我代码的开始部分,只是加载数据

some_digit  =   X[880] 
some_digit_image = some_digit.reshape(28,   28)

错误部分

ValueError                                Traceback (most recent call last)
<ipython-input-15-4d618bdb57bc> in <module>
      1 some_digit = X[880]
----> 2 some_digit_image = some_digit.reshape(28,28)

ValueError: cannot reshape array of size 64 into shape (28,28)

【问题讨论】:

  • 嗯,28 * 28 != 64,所以你显然不能这样重塑它们

标签: python-3.x image machine-learning reshape mnist


【解决方案1】:

您只能将其重塑为 8、8 数组。 8x8=64

【讨论】:

    【解决方案2】:

    尝试:

    some_digit  =   X[880] 
    some_digit_image = some_digit.reshape(8,   8)
    

    【讨论】:

      猜你喜欢
      • 2020-10-15
      • 2020-02-18
      • 2020-04-14
      • 2020-10-05
      • 2020-01-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多