'Compute loss function.
Args:
prediction_tensor: A float tensor of shape [batch_size, num_anchors,
num_classes] representing the predicted logits for each class
target_tensor: A float tensor of shape [batch_size, num_anchors,
num_classes] representing one-hot encoded classification targets
weights: a float tensor of shape [batch_size, num_anchors]
Returns:
loss: a (scalar) tensor representing the value of the loss function
or a float tensor of shape [batch_size, num_anchors]'

def _compute_loss(self, prediction_tensor, target_tensor, weights):

    if (self._bootstrap_type == 'soft'):
        bootstrap_target_tensor = ((self._alpha * target_tensor) + ((1.0 - self._alpha) * tf.sigmoid(prediction_tensor)))
    else:
        bootstrap_target_tensor = ((self._alpha * target_tensor) + ((1.0 - self._alpha) * tf.cast((tf.sigmoid(prediction_tensor) > 0.5), tf.float32)))
    per_entry_cross_ent = tf.nn.sigmoid_cross_entropy_with_logits(labels=bootstrap_target_tensor, logits=prediction_tensor)
    if self._anchorwise_output:
        return tf.reduce_sum((per_entry_cross_ent * tf.expand_dims(weights, 2)), 2)
    return tf.reduce_sum((per_entry_cross_ent * tf.expand_dims(weights, 2)))
