Ejemplo n.º 1
0
 def create_loss(self, features, mode, logits, labels):
   """See `Head`."""
   del mode, features  # Unused for this head.
   processed_labels = self._process_labels(labels)
   unweighted_loss = losses.sigmoid_cross_entropy(
       multi_class_labels=processed_labels, logits=logits,
       reduction=losses.Reduction.NONE)
   return head_lib.LossAndLabels(
       unweighted_loss=unweighted_loss,
       processed_labels=processed_labels)
Ejemplo n.º 2
0
 def create_loss(self, features, mode, logits, labels):
   """See `Head`."""
   del mode, features  # Unused for this head.
   processed_labels = self._process_labels(labels)
   unweighted_loss = losses.sigmoid_cross_entropy(
       multi_class_labels=processed_labels, logits=logits,
       reduction=losses.Reduction.NONE)
   # Averages loss over classes.
   unweighted_loss = math_ops.reduce_mean(
       unweighted_loss, axis=-1, keep_dims=True)
   return head_lib.LossAndLabels(
       unweighted_loss=unweighted_loss,
       processed_labels=processed_labels)