python - 在 keras 模型中输入时,我的输入 np 数组变成不同的形状
问题描述
图像的形状为,(512, 2048, 3)
但运行时出现 ValueError preds_train = new_model.predict(img, batch_size=1)
:
ValueError: Could not find matching function to call loaded from the SavedModel. Got:
Positional arguments (3 total):
* Tensor("inputs:0", shape=(1, 2048, 3), dtype=float32)
* False
* None
Keyword arguments: {}
Expected these arguments to match one of the following 4 option(s):
Option 1:
Positional arguments (3 total):
* TensorSpec(shape=(None, 512, 2048, 3), dtype=tf.float32, name='inputs')
* True
* None
Keyword arguments: {}
Option 2:
Positional arguments (3 total):
* True
* None
Keyword arguments: {}
Option 3:
Positional arguments (3 total):
* TensorSpec(shape=(None, 512, 2048, 3), dtype=tf.float32, name='input_1')
* False
* None
Keyword arguments: {}
Option 4:
Positional arguments (3 total):
* TensorSpec(shape=(None, 512, 2048, 3), dtype=tf.float32, name='inputs')
* False
* None
Keyword arguments: {}
我已经打印了形状的初始尺寸,所以我确定它是(512, 2048, 3)
,另外,当我训练模型时,我使用该形状的图像这样做。我不知道为什么我不能测试模型。
解决方案
尝试使用 model.evaluate(x_test)
推荐阅读
- c# - 在 NetCore 3 Preview 6 中从插件 Dll 注册控制器
- camera - 使用激光雷达图像和相机图像执行对象检测
- python - 与 python 的 sorted() 类似,按键对 pandas 数据帧中的值进行排序
- excel - 无法为使用 PhpExcel 生成的 .xlsm 文件启用内容
- c# - 通过 UI 自动化设置父级
- react-native - 将 Expo React Native App.js 更改为不同的文件
- java - 检测到有缺陷的令牌(机制级别:检测到有缺陷的令牌(机制级别:无效的 SPNEGO NegTokenTarg 令牌:DER 长度的短读取))
- jms - ActiveMQ Artemis / RedHat AMQ 是否没有正确设置 JMS 消息 ID?
- php - php从文件中访问文件夹
- c# - TPL 数据流 - 与事件流一起使用