【发布时间】: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