小编jad*_*_96的帖子

Keras Inception-V3 模型预测还很遥远

因此,我运行了使用 inception-v3 模型的 Keras 示例代码,结果与预测相差甚远。我猜权重有错误。有人知道为什么会发生这种情况吗?

我正在使用:Keras 2.0.4,Python 3.5(64位)

https://github.com/fchollet/keras/blob/master/keras/applications/inception_v3.py

这是我正在运行的代码:

import numpy as np
from keras.applications.inception_v3 import InceptionV3
from keras.preprocessing import image
from keras.applications.imagenet_utils import preprocess_input, decode_predictions

if __name__ == '__main__':
    model = InceptionV3(include_top=True, weights='imagenet')

    img_path = 'elephant.jpg'
    img = image.load_img(img_path, target_size=(299, 299))
    x = image.img_to_array(img)
    x = np.expand_dims(x, axis=0)

    x = preprocess_input(x)

    preds = model.predict(x)
    print('Predicted:', decode_predictions(preds))
Run Code Online (Sandbox Code Playgroud)

给出的结果是:

Predicted: [[('n01924916', 'flatworm', 0.99995065), ('n03047690', 'clog', 4.9389007e-05), ('n04366367', 'suspension_bridge', 1.075191e-08), ('n01665541', 'leatherback_turtle', 2.5111552e-10), ('n03950228', 'pitcher', 6.6290827e-11)]]
Run Code Online (Sandbox Code Playgroud)

当我通过 ResNet50 模型运行相同的图像时,它给出了以下结果:

Predicted: [[('n02504458', …
Run Code Online (Sandbox Code Playgroud)

machine-learning neural-network python-3.x deep-learning keras

5
推荐指数
1
解决办法
2253
查看次数