Multilabel image classification with sparse labels?
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 ->Label true / Image belongs to this class
- -1.0 ->Label false / Image does not contain to this class.
- 0.0 ->missing value/label
E.g.: V= {1.0,-1.0,1.0, 0.0}
For this example V the model should learn, that the corresponding image should be classified in the first and third class.
My problem is currently how to handle the missing values/labels. I've searched through the issues and found this issue: https://github.com/tensorflow/skflow/issues/113
So could do multilable image classification with: tf.nn.sigmoid_cross_entropy_with_logits(logits, targets, 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)
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.
Thanks for the question @zorancupic!
We primarily use github issues to track bugs and installation problems. This is a question better suited for StackOverflow. Please ask it there and tag it with the tensorflow tag. Thanks!
@tatatodd But what about feature requests? It seems to me that @zorancupic is asking for a cost functional tf.nn.sparse_sigmoid_cross_entropy_with_logits(logits, labels, name=None) analogously to the already provided ``tf.nn.sparse_softmax_cross_entropy_with_logits(logits, labels, name=None)`.
@tatatodd I asked this question on Stackoverflow and didn't get the answer, that this cost function is provided in TensorFlow. But like @FlorianWilhelm mentioned, this would be a good Feature Request. Sparse labels and the multilabel image classification task often occur.
Here is the link to the StackOverflow question: http://stackoverflow.com/questions/39697216/multilabel-image-classification-with-sparse-labels-in-tensorflow/39737057?noredirect=1#comment66817206_39737057
@zorancupic @FlorianWilhelm My apologies, I missed the feature request for adding a tf.nn.sparse_sigmoid_cross_entropy_with_logits function.
We definitely welcome pull requests for new functionality!
So looking at this issue and the documentation of tf.nn.sparse_softmax_cross_entropy_with_logits, again I think there might be some confusion here about the word "sparse" here. This function is actually only a shortcut for a one-hot encoding and applying tf.nn.softmax_cross_entropy_with_logits afterwards as explained here. I think @zorancupic understanding and also mine was that "sparse" allows handling of missing labels. Since this is not the case, a method like tf.nn.sparse_sigmoid_cross_entropy_with_logits makes no sense at all I guess.
Regarding the problem of missing labels, I think one could easily solve the problem by applying one of TensorFlow's loss functions that has a weight parameter, e.g. tf.contrib.losses.log_loss. Using a binary vector as weight that is 0 for missing values and 1 for known labels should do the trick.
Automatically closing due to lack of recent activity. Since this issue is old at this point, please reopen the issue if it still occurs when tried with the latest version of Tensorflow. Thank you.