简体   繁体   English

ValueError:层顺序的输入 0 与层不兼容:预期 ndim=4,发现 ndim=3。 收到的完整形状:[32, 64, 3]

[英]ValueError: Input 0 of layer sequential is incompatible with the layer: expected ndim=4, found ndim=3. Full shape received: [32, 64, 3]

I am absolutely beginner in the deep learning, I am trying to build simple classification model by using the Tensorflow.我绝对是深度学习的初学者,我正在尝试使用 Tensorflow 构建简单的分类模型。 Of course, I want to save my model after training by using this command.当然,我想使用此命令在训练后保存我的模型。

model.save('saved_model/my_model')

after that, I want to use my model another place as well as on the raspberry pi.在那之后,我想在另一个地方以及在树莓派上使用我的模型。 But, I got some error:但是,我遇到了一些错误:

ValueError: Input 0 of layer sequential is incompatible with the layer: expected ndim=4, found ndim=3. ValueError:层顺序的输入 0 与层不兼容:预期 ndim=4,发现 ndim=3。 Full shape received: [32, 64, 3]收到的完整形状:[32, 64, 3]

Here is my model structure:这是我的模型结构: 我的模特

Here is my test code:这是我的测试代码:

在此处输入图片说明

My fault, Perhaps I couldn't research enough.我的错,也许我研究得不够。 But, I have found the solution.但是,我已经找到了解决方案。

In the model the data is normalized by being devided by 255.在模型中,数据通过除以 255 进行归一化。

...
img = img / 255.0
img = cv2.resize(img, (64, 64))
...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ValueError:层顺序的输入 0 与层不兼容::预期 min_ndim=4,发现 ndim=3。 收到的完整形状:[None, 32, 32] - ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: [None, 32, 32] ValueError:layersequence_4 的输入 0 与 layer 不兼容::预期 min_ndim=4,发现 ndim=3。 收到的完整形状:(32、224、3) - ValueError: Input 0 of layer sequential_4 is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: (32, 224, 3) ValueError: 层序列 9 的输入 0 与层不兼容:预期 min_ndim=4,发现 ndim=3。 收到的完整形状:[无,无,无] - ValueError: Input 0 of layer sequential_9 is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: [None, None, None] ValueError:layersequential_1 的输入 0 与 layer 不兼容::预期 min_ndim=4,发现 ndim=3。 收到的完整形状:[无、256、256] - ValueError: Input 0 of layer sequential_1 is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: [None, 256, 256] ValueError: 层序贯_4 的输入 0 与层不兼容:预期 ndim=4,发现 ndim=3。 收到的完整形状:(无,1188,6) - ValueError: Input 0 of layer sequential_4 is incompatible with the layer: expected ndim=4, found ndim=3. Full shape received: (None, 1188, 6) ValueError:顺序层的输入 0 与层不兼容::预计 min_ndim=4,发现 ndim=3。 收到完整形状:[8, 28, 28] - ValueError: Input 0 of layer sequential is incompatible with the layer: : expected min_ndim=4, found ndim=3. Full shape received: [8, 28, 28] ValueError: 层序的输入 0 与层不兼容:预期 ndim=4,发现 ndim=3。 收到的完整形状:(无、28、28) - ValueError: Input 0 of layer sequential is incompatible with the layer: expected ndim=4, found ndim=3. Full shape received: (None, 28, 28) ValueError: 层序的输入 0 与层不兼容:预期 ndim=3,发现 ndim=2。 收到的完整形状:(57, 1) - ValueError: Input 0 of layer sequential is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (57, 1) ValueError: 层序号_9 的输入 0 与层不兼容:预期 ndim=4,发现 ndim=0。 收到的完整形状:[] - ValueError: Input 0 of layer sequential_9 is incompatible with the layer: expected ndim=4, found ndim=0. Full shape received: [] ValueError: 层序的输入 0 与层不兼容:预期 ndim=3,发现 ndim=2。 收到的完整形状:(无,1) - ValueError: Input 0 of layer sequential is incompatible with the layer: expected ndim=3, found ndim=2. Full shape received: (None, 1)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM