小编ran*_* hd的帖子

验证准确性非常好,但预测很差

我正在构建一个 keras 模型来对猫和狗进行分类。我使用具有瓶颈特征的迁移学习和 vgg 模型的微调。现在我得到了非常好的验证准确率,例如 97%,但是当我进行预测时,我得到了关于分类报告和混淆矩阵的非常糟糕的结果。可能是什么问题呢?

这是微调的代码和我得到的结果

base_model = applications.VGG16(weights='imagenet', include_top=False, input_shape=(150,150,3))
print('Model loaded.')

# build a classifier model to put on top of the convolutional model
top_model = Sequential()
top_model.add(Flatten(input_shape=base_model.output_shape[1:]))
top_model.add(Dense(256, activation='relu'))
top_model.add(Dropout(0.5))
top_model.add(Dense(2, activation='sigmoid'))

# note that it is necessary to start with a fully-trained
# classifier, including the top classifier,
# in order to successfully do fine-tuning
top_model.load_weights(top_model_weights_path)

# add the model on top of the convolutional base
# model.add(top_model)
model = Model(inputs=base_model.input, outputs=top_model(base_model.output))

# set the …
Run Code Online (Sandbox Code Playgroud)

conv-neural-network keras

5
推荐指数
2
解决办法
5415
查看次数

标签 统计

conv-neural-network ×1

keras ×1