machine-learning - 需要帮助选择损失函数

标签 machine-learning neural-network deep-learning conv-neural-network loss-function

我使用resnet50来解决多类分类问题。该模型输出每个类的概率。我应该为我的模型选择哪种损失函数?

选择二进制交叉熵后: enter image description here

选择分类交叉熵后: enter image description here

以上结果适用于具有不同损失函数的同一模型。该模型应该将图像分类为 26 个类别,因此分类交叉熵应该起作用。 此外,在第一种情况下,准确率约为 96%,但损失却如此之高。为什么?

编辑2: 模型架构: enter image description here

enter image description here

enter image description here

enter image description here

最佳答案

你肯定需要使用categorical_crossentropy对于多分类问题。 binary_crossentropy将以一种不清楚的方式将您的问题简化为二元分类问题,无需进一步研究。

我想说,您在第一种情况(以及在某种程度上第二种情况)中看到高精度的原因是因为您过度拟合。您要添加的第一个密集层包含 800 万个参数(!!!看到这样做 model.summary() ),并且您只有 70k 图像来训练它 8 个时期。这种架构选择对计算能力和数据要求都非常高。您还使用了一个非常基本的优化器( SGD )。尝试使用更强大的 Adam .

最后,我对您选择 'sigmoid' 感到有点惊讶输出层的激活函数。为什么不来个更经典的'softmax'

关于machine-learning - 需要帮助选择损失函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55991658/

相关文章:

machine-learning - 推广具有大状态和 Action 空间的基于模型的强化学习算法的策略

python - 值错误: Unknown metric function when using custom metric in Keras

machine-learning - Tensorflow:权重衰减与 Logits 标准化

python - 在keras中使用predict_generator()时如何获取关联的图像名称

neural-network - 人工神经网络中的操作

python - CIFAR-10 无意义的归一化值

machine-learning - 属性错误: module 'tensorflow' has no attribute 'placeholder'

python - 从 TensorFlow 中的检查点恢复后修改变量名称

Python信息获取实现

python - Keras SeparableConv2D 简单示例?