[英]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.