【发布时间】:2017-06-14 02:49:15
【问题描述】:
我正在使用 keras 的预训练模型 VGG16,点击此链接:Keras VGG16 我正在尝试将预测输出解码为图像中的单词:
model = VGG16(weights='imagenet', include_top=False)
img_path = 'elephant.jpg'
img = image.load_img(img_path, target_size=(224, 224))
x = image.img_to_array(img)
x = np.expand_dims(x, axis=0)
x = preprocess_input(x)
features = model.predict(x)
(inID, label) = decode_predictions(features)[0] #ERROR HERE
完整的错误是:
ValueError:
decode_predictions需要一批预测(即 形状的二维数组(样本,1000))。找到具有形状的数组:(1, 7, 7, 512)
非常感谢任何 cmets 或建议。谢谢。
【问题讨论】:
标签: numpy machine-learning neural-network deep-learning keras