【发布时间】:2020-01-02 05:58:09
【问题描述】:
所以我有一个灰度图像形式的数据集,这意味着一个通道对吗?
我从这段代码中将 input_shape 更改为 64.64.1
classifier.add(ZeroPadding2D(padding=(2,2), input_shape = (64, 64, 1)))
但我有错误
Error when checking input: expected zero_padding2d_1_input to have shape (64, 64, 1) but got array with shape (64, 64, 3)
这有什么问题,如何使用一个通道 input_shape (64,64,1) 进行训练?
你可以在Why my acc always higher but my val_acc is very small?上看到完整的代码
【问题讨论】:
-
在原始代码的第一层,您的 input_shape 为 (64,64,3) 。如果您想将其训练为 (64,64,1) 将您的图像转换为灰度并变为 (64,64) 然后在 -1 处扩展暗淡,因此变为 (64,64,1)
-
谢谢回复,能否提供将文件夹中所有图像更改为灰度的代码?我已经搜索过,但它只能转换一张图像。我真的需要这个
-
你可以试试 imagemagick - stackoverflow.com/questions/53262968/…
-
我试试这个代码(结束页)stackoverflow.com/questions/47087528/…。它可以将我所有的图像转换为灰度。但是当我尝试再次运行我的 cnn 模型时,它仍然给出错误 ValueError: Error when checks input: expected zero_padding2d_1_input to have shape (64, 64, 1) but got array with shape (64, 64, 3)
-
太好了,非常感谢兄弟 :)
标签: python machine-learning keras deep-learning