【发布时间】:2019-06-14 15:05:11
【问题描述】:
背景
我有 5 个标签的多标签分类问题(例如[1 0 1 1 0])。因此,我希望我的模型在固定召回、精确召回 AUC 或 ROC AUC 等指标上有所改进。
使用与我要优化的性能测量没有直接关系的损失函数(例如binary_crossentropy)是没有意义的。因此,我想使用TensorFlow的global_objectives.recall_at_precision_loss()或类似的损失函数。
- 相关GitHub: https://github.com/tensorflow/models/tree/master/research/global_objectives
- 相关论文(Scalable Learning of Non-Decomposable Objectives):https://arxiv.org/abs/1608.04802
非公制
我不是在寻找实现tf.metrics。我已经成功了:https://stackoverflow.com/a/50566908/3399066
问题
我认为我的问题可以分为2个问题:
- 如何使用
global_objectives.recall_at_precision_loss()或类似的? - 如何在带有 TF 后端的 Keras 模型中使用它?
问题 1
the global objectives GitHub page (same as above) 上有一个名为 loss_layers_example.py 的文件。但是,由于我对 TF 没有太多经验,所以我不太了解如何使用它。此外,谷歌搜索 TensorFlow recall_at_precision_loss example 或 TensorFlow Global objectives example 不会给我任何更清楚的例子。
如何在一个简单的 TF 示例中使用global_objectives.recall_at_precision_loss()?
问题 2
类似(在 Keras 中):model.compile(loss = ??.recall_at_precision_loss, ...) 就足够了吗?
我的感觉告诉我它比这更复杂,因为使用了loss_layers_example.py 中使用的全局变量。
如何在 Keras 中使用类似于global_objectives.recall_at_precision_loss() 的损失函数?
【问题讨论】:
-
嗨!我也在尝试将 Global Objectives 的损失函数集成到 Keras 中。您找到解决问题的方法了吗?
-
我不认为我找到了解决方案,但是使用集成 Keras 的 TensorFlow 2.0 可能会更容易?
-
原来的链接现在被破坏了,因为 TF 不再维护它了。 New link pointing to archive location
标签: tensorflow keras loss-function auc precision-recall