【问题标题】:ValueError: Input 0 of layer "model_3" is incompatible with the layer: expected shape=(None, 224, 224, 3), found shape=(32, 224, 3)ValueError: 层“model_3”的输入 0 与层不兼容:预期形状=(None, 224, 224, 3),找到形状=(32, 224, 3)
【发布时间】:2022-06-15 04:00:22
【问题描述】:

我有以下代码:

model = DeepFace.build_model('VGG-Face')
print(img.shape) # (224, 224, 3)
print(model.input_shape) # (None, 224, 224, 3)
representation = model.predict(img)
print(representation)
return representation

但我收到以下错误:

ValueError: Input 0 of layer "model_3" is incompatible with the layer: expected shape=(None, 224, 224, 3), found shape=(32, 224, 3)

那么,我如何将 img 重塑为 (None, 224, 224, 3)

谢谢

【问题讨论】:

  • 通过np.expand_dims(img, axis=0)添加批量维度,然后进行预测。

标签: python tensorflow keras


猜你喜欢
  • 2022-06-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-03-30
  • 2021-02-12
  • 1970-01-01
  • 1970-01-01
  • 2021-06-16
相关资源
最近更新 更多