def _compute_mask_loss(self, segmentation_predictions, per_pixel_weights):
    'Computes the mask loss.\n\n    Args:\n      segmentation_predictions: A list of float32 tensors of shape [batch_size,\n        out_height, out_width, num_classes].\n      per_pixel_weights: A float tensor of shape [batch_size,\n        out_height * out_width, 1] with 1s in locations where the spatial\n        coordinates fall within the height and width in true_image_shapes.\n\n    Returns:\n      A float scalar tensor representing the mask loss.\n    '
    gt_masks_list = self.groundtruth_lists(fields.BoxListFields.masks)
    gt_classes_list = self.groundtruth_lists(fields.BoxListFields.classes)
    assigner = self._target_assigner_dict[SEGMENTATION_TASK]
    heatmap_targets = assigner.assign_segmentation_targets(gt_masks_list=gt_masks_list, gt_classes_list=gt_classes_list)
    flattened_heatmap_targets = _flatten_spatial_dimensions(heatmap_targets)
    loss = 0.0
    mask_loss_fn = self._mask_params.classification_loss
    total_pixels_in_loss = tf.reduce_sum(per_pixel_weights)
    for pred in segmentation_predictions:
        pred = _flatten_spatial_dimensions(pred)
        loss += mask_loss_fn(pred, flattened_heatmap_targets, weights=per_pixel_weights)
    total_loss = (tf.reduce_sum(loss) / (float(len(segmentation_predictions)) * total_pixels_in_loss))
    return total_loss
Computes the mask loss.

Args:
  segmentation_predictions: A list of float32 tensors of shape [batch_size,
    out_height, out_width, num_classes].
  per_pixel_weights: A float tensor of shape [batch_size,
    out_height * out_width, 1] with 1s in locations where the spatial
    coordinates fall within the height and width in true_image_shapes.

Returns:
  A float scalar tensor representing the mask loss.
def _compute_mask_loss(self, segmentation_predictions, per_pixel_weights):
    'Computes the mask loss.\n\n    Args:\n      segmentation_predictions: A list of float32 tensors of shape [batch_size,\n        out_height, out_width, num_classes].\n      per_pixel_weights: A float tensor of shape [batch_size,\n        out_height * out_width, 1] with 1s in locations where the spatial\n        coordinates fall within the height and width in true_image_shapes.\n\n    Returns:\n      A float scalar tensor representing the mask loss.\n    '
    gt_masks_list = self.groundtruth_lists(fields.BoxListFields.masks)
    gt_classes_list = self.groundtruth_lists(fields.BoxListFields.classes)
    assigner = self._target_assigner_dict[SEGMENTATION_TASK]
    heatmap_targets = assigner.assign_segmentation_targets(gt_masks_list=gt_masks_list, gt_classes_list=gt_classes_list)
    flattened_heatmap_targets = _flatten_spatial_dimensions(heatmap_targets)
    loss = 0.0
    mask_loss_fn = self._mask_params.classification_loss
    total_pixels_in_loss = tf.reduce_sum(per_pixel_weights)
    for pred in segmentation_predictions:
        pred = _flatten_spatial_dimensions(pred)
        loss += mask_loss_fn(pred, flattened_heatmap_targets, weights=per_pixel_weights)
    total_loss = (tf.reduce_sum(loss) / (float(len(segmentation_predictions)) * total_pixels_in_loss))
    return total_loss