【发布时间】:2021-07-18 09:10:24
【问题描述】:
当我尝试在 Google colab 中运行这部分代码来训练 cnn 时,我遇到了这个错误:
ValueError Traceback (most recent call last) <ipython-input-12-0b1325cd4065> in <module>()
3 for xseq in datapoints:
4 xx = [int(xp) for xp in xseq.split(' ')]
----> 5 xx = np.asarray(xx).reshape(width, height)
6 X.append(xx.astype('float32'))
7 ValueError: cannot reshape array of size 2251 into shape (48,48)
我的代码
# getting features for training
X = []
for xseq in datapoints:
xx = [int(xp) for xp in xseq.split(' ')]
xx = np.asarray(xx).reshape(width, height)
X.append(xx.astype('float32'))
【问题讨论】:
-
请注意,在错误之后出现的任何代码都与问题无关(从未执行),不应在此处发布,因为它只会造成不必要的混乱(已编辑出)。
-
@desertnaut 我已经删除了不必要的代码
-
您删除了 all 代码,这不是的想法;正如评论中所说,我已经自己编辑了多余的代码,所以不需要自己做任何其他事情,评论是为了将来(回滚)。
标签: python-3.x numpy deep-learning conv-neural-network