def _compute_lossses(self, batch, fwd_data):
    ret = {}
    target_distance_fields = batch['distance_fields']
    target_alignment_fields = batch['alignment_fields']
    target_occupancy_fields = batch['occupancy_fields']
    if self.cuda:
        target_distance_fields = target_distance_fields.cuda()
        target_alignment_fields = target_alignment_fields.cuda()
        target_occupancy_fields = target_occupancy_fields.cuda()
    distance_fields = fwd_data['distance_fields']
    alignment_fields = fwd_data['alignment_fields']
    occupancy_fields = fwd_data['occupancy_fields']
    surfaceloss = th.mean(((target_occupancy_fields * distance_fields) + (target_distance_fields * occupancy_fields)))
    alignmentloss = th.mean((1 - (th.sum((target_alignment_fields * alignment_fields), dim=(- 1)) ** 2)))
    ret['surfaceloss'] = surfaceloss
    ret['alignmentloss'] = alignmentloss
    loss = ((self.w_surface * surfaceloss) + (self.w_alignment * alignmentloss))
    ret['loss'] = loss
    return ret
def _compute_lossses(self, batch, fwd_data):
    ret = {}
    target_distance_fields = batch['distance_fields']
    target_alignment_fields = batch['alignment_fields']
    target_occupancy_fields = batch['occupancy_fields']
    if self.cuda:
        target_distance_fields = target_distance_fields.cuda()
        target_alignment_fields = target_alignment_fields.cuda()
        target_occupancy_fields = target_occupancy_fields.cuda()
    distance_fields = fwd_data['distance_fields']
    alignment_fields = fwd_data['alignment_fields']
    occupancy_fields = fwd_data['occupancy_fields']
    surfaceloss = th.mean(((target_occupancy_fields * distance_fields) + (target_distance_fields * occupancy_fields)))
    alignmentloss = th.mean((1 - (th.sum((target_alignment_fields * alignment_fields), dim=(- 1)) ** 2)))
    ret['surfaceloss'] = surfaceloss
    ret['alignmentloss'] = alignmentloss
    loss = ((self.w_surface * surfaceloss) + (self.w_alignment * alignmentloss))
    ret['loss'] = loss
    return ret