小编Hir*_*iro的帖子

Keras 中同一数据集的 fit() 和 evaluate() 的不同精度

我编写 Keras 代码来训练 GoogleNet。然而,fit() 得到的准确率是 100%,而用同样的训练数据集 evaluate() ,准确率只有 25%,差距如此之大!此外,与 fit() 不同,evaluate() 的准确率不会因训练次数而提高,这意味着它几乎保持在 25%。

有谁知道这种情况出了什么问题吗?

# Training Dataset and labels r given. Here load GoogleNet model
from keras.models import load_model
model = load_model('FT_InceptionV3.h5')
# Training Phase
model.fit(x=X_train, 
              y=y_train, 
              batch_size=5, 
              epochs=20, 
              validation_split=0,
              #callbacks=[tensorboard]
             )

#Testing Phase
train_loss , train_acc=model.evaluate(X_train, y_train, verbose=1)
print("Train loss=",train_loss,"Train accuracy",train_acc)
Run Code Online (Sandbox Code Playgroud)

训练结果

测试结果

python keras

6
推荐指数
1
解决办法
1531
查看次数

标签 统计

keras ×1

python ×1