(segms, mask_roi_indices, gt_segms, gt_mask_labels,
                        batchsize)
return mask_loss
Loss function for Mask Head (post).

     Args:
         segms (array): An array whose shape is :math:`(R, n\_class, M, M)`,
             where :math:`R` is the total number of RoIs in the given batch.
         mask_roi_indices (array): A list of arrays returned by
             :func:`mask_head_loss_pre`.
         gt_segms (list of arrays): A list of arrays returned by
             :func:`mask_head_loss_pre`.
         gt_mask_labels (list of arrays): A list of arrays returned by
             :func:`mask_head_loss_pre`.
         batchsize (int): The size of batch.

     Returns:
        chainer.Variable:
        Mask loss.
Loss function for Mask Head (post).
Loss function for Mask Head ( post ) .
def mask_head_loss_post(segms, mask_roi_indices, gt_segms, gt_mask_labels,
                        batchsize):
    """Loss function for Mask Head (post).

     Args:
         segms (array): An array whose shape is :math:`(R, n\_class, M, M)`,
             where :math:`R` is the total number of RoIs in the given batch.
         mask_roi_indices (array): A list of arrays returned by
             :func:`mask_head_loss_pre`.
         gt_segms (list of arrays): A list of arrays returned by
             :func:`mask_head_loss_pre`.
         gt_mask_labels (list of arrays): A list of arrays returned by
             :func:`mask_head_loss_pre`.
         batchsize (int): The size of batch.

     Returns:
        chainer.Variable:
        Mask loss.
    """
    xp = cuda.get_array_module(segms.array)

    mask_roi_indices = xp.hstack(mask_roi_indices).astype(np.int32)
    gt_segms = xp.vstack(gt_segms)
    gt_mask_labels = xp.hstack(gt_mask_labels).astype(np.int32)

    mask_loss = F.sigmoid_cross_entropy(
        segms[np.arange(len(gt_mask_labels)), gt_mask_labels],
        gt_segms.astype(np.int32))
    return mask_loss
def mask_head_loss_post ( segms , mask_roi_indices , gt_segms , gt_mask_labels , batchsize ) : xp = cuda . get_array_module ( segms . array ) mask_roi_indices = xp . hstack ( mask_roi_indices ) . astype ( np . int32 ) gt_segms = xp . vstack ( gt_segms ) gt_mask_labels = xp . hstack ( gt_mask_labels ) . astype ( np . int32 ) mask_loss = F . sigmoid_cross_entropy ( segms [ np . arange ( len ( gt_mask_labels ) ) , gt_mask_labels ] , gt_segms . astype ( np . int32 ) ) return mask_loss