title: How can I mask outputs as "not-available / don't train" in Keras?
body: <p>Assume I have a network which should learn two different tasks, e.g. recognizing if an image contains a cat, a dog or both. Let's say we have only some of the labels. So for some images we know there is a cat, for some we know there is no cat, for some we know there is a dog and for some we know there is no dog. The labels then look like this (dogs first, cats second):</p>
  
  <pre><code>[[None, 1]. [None, 0], [None, 0], [1, None], ...]
  </code></pre>
  
  <p>meaning</p>
  
  <ul>
  <li>for the first entry we know that a cat is present, but we don't know if there is a dog</li>
  <li>for the second entry we know there is no cat, but we don't know if there is a dog.</li>
  <li>for the third entry we know there is no cat, but we don't know if there is a dog.</li>
  <li>for the forth entry we know it is a dog, but not if there is a cat or not.</li>
  </ul>
  
  <p>Of course those labels can easily be split in two parts:</p>
  
  <ul>
  <li>labels: <code>[[-1, 1]. [-1, 0], [-1, 0], [1, -1], ...]</code></li>
  <li>mask: <code>[[1, 0]. [1, 0], [1, 0], [0, 1], ...]</code> - part that should be ignored for gradient calculation.</li>
  </ul>
  
  <p>How can I mask the gradient for those kinds of labels, so that it doesn't try to learn when there is <code>None</code>?</p>