TensorFlow中具有稀疏标签的多标签图像分类? [英] Multilabel image classification with sparse labels in TensorFlow?

查看:324
本文介绍了TensorFlow中具有稀疏标签的多标签图像分类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想对n个类执行多标签图像分类任务。
我为每个图像都得到了稀疏的标签向量,并且每个标签向量的每个维当前都以这种方式编码:

I want to perform a multilabel image classification task for n classes. I've got sparse label vectors for each image and each dimension of each label vector is currently encoded in this way:

1.0->标签为真/图像属于此类

1.0 ->Label true / Image belongs to this class

-1.0->标签错误/图片不包含此类。

-1.0 ->Label false / Image does not contain to this class.

0.0 ->缺失值/标签

0.0 ->missing value/label

例如:V = {1.0,-1.0,1.0,0.0}

E.g.: V= {1.0,-1.0,1.0, 0.0}

对于此示例V,模型应学习到,相应的图像应分类为第一类和第三类。

For this example V the model should learn, that the corresponding image should be classified in the first and third class.

我目前的问题是如何处理缺失的值/标签。我搜索了所有问题并发现了这个问题:
tensorflow / skflow#113 在这里找到

My problem is currently how to handle the missing values/labels. I've searched through the issues and found this issue: tensorflow/skflow#113 found here

因此可以使用以下方法进行多重图像分类:
tf.nn.sigmoid_cross_entropy_with_logits(logits,target,name = None)

So could do multilable image classification with: tf.nn.sigmoid_cross_entropy_with_logits(logits, targets, name=None)

但是TensorFlow具有针对稀疏softmax的此错误函数,用于专有分类:
tf.nn.sparse_softmax_cross_entropy_with_logits(logits,labels,name = None)

but TensorFlow has this error function for sparse softmax, which is used for exclusive classification: tf.nn.sparse_softmax_cross_entropy_with_logits(logits, labels, name=None)

那么有稀疏的S型交叉熵吗? (找不到任何东西)或任何建议,如何处理稀疏标签的多标签分类问题。

So is there something like sparse sigmoid cross entropy? (Couldn't find something) or any suggestions how can I handle my multilabel classification problem with sparse labels.

推荐答案

我使用了 weighted_cross_entropy_with_logits 作为损失函数,权重为正数1s。

I used weighted_cross_entropy_with_logits as the loss function with positive weights for 1s.

在我来说,所有标签都同样重要。但是0出现在任何标签上的可能性是1的十倍。

In my case, all the labels are equally important. But 0 was ten times more likely to be appeared as the value of any label than 1.

所以我通过调用 pos_weight权衡了所有1。前述损失函数的 参数。我使用的pos_weight(=正值的权重)为10。顺便说一句,我不建议使用任何策略来计算pos_weight。我认为这将明确取决于手中的数据。

So I weighed all the 1s by calling the pos_weight parameter of the aforementioned loss function. I used a pos_weight (= weight on positive values) of 10. By the way, I do not recommend any strategy to calculate the pos_weight. I think it will depend explicitly on the data in hand.

如果实数标签= 1,则
weighted_cross_entropy = pos_weight * sigmoid_cross_entropy

具有logits的加权交叉熵与具有 log的Sigmoid交叉熵相同,只是将额外权重值乘以所有 个目标正实际价值 ,即; 1.

Weighted cross entropy with logits is same as the Sigmoid cross entropy with logits, except for the extra weight value multiplied to all the targets with a positive real value i.e.; 1.

从理论上讲,它应该可以完成工作。我仍在调整其他参数以优化性能。稍后会更新性能统计信息。

Theoretically, it should do the job. I am still tuning other parameters to optimize the performance. Will update with performance statistics later.

这篇关于TensorFlow中具有稀疏标签的多标签图像分类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆