parameters: (self, y_true_cls, y_pred_cls,
               y_true_geo, y_pred_geo,
               training_mask)
return_statement: return tf.reduce_mean(L_g * y_true_cls * training_mask) + classification_loss
docstring: define the loss used for training, contraning two part,
          the first part we use dice loss instead of weighted logloss,
          the second part is the iou loss defined in the paper
          :param y_true_cls: ground truth of text
          :param y_pred_cls: prediction os text
          :param y_true_geo: ground truth of geometry
          :param y_pred_geo: prediction of geometry
          :param training_mask: mask used in training, to ignore some text annotated by ###
          :return:
docstring_summary: define the loss used for training, contraning two part,
          the first part we use dice loss instead of weighted logloss,
          the second part is the iou loss defined in the paper
          :param y_true_cls: ground truth of text
          :param y_pred_cls: prediction os text
          :param y_true_geo: ground truth of geometry
          :param y_pred_geo: prediction of geometry
          :param training_mask: mask used in training, to ignore some text annotated by ###
          :return:
docstring_tokens: define the loss used for training contraning two part the first part we use dice loss instead of weighted logloss the second part is the iou loss defined in the paper : param y_true_cls : ground truth of text : param y_pred_cls : prediction os text : param y_true_geo : ground truth of geometry : param y_pred_geo : prediction of geometry : param training_mask : mask used in training to ignore some text annotated by ### : return :
function: def loss(self, y_true_cls, y_pred_cls,
               y_true_geo, y_pred_geo,
               training_mask):
          '''
          define the loss used for training, contraning two part,
          the first part we use dice loss instead of weighted logloss,
          the second part is the iou loss defined in the paper
          :param y_true_cls: ground truth of text
          :param y_pred_cls: prediction os text
          :param y_true_geo: ground truth of geometry
          :param y_pred_geo: prediction of geometry
          :param training_mask: mask used in training, to ignore some text annotated by ###
          :return:
          '''
          classification_loss = self.dice_coefficient(y_true_cls, y_pred_cls, training_mask)
          # scale classification loss to match the iou loss part
          classification_loss *= 0.01
  
          # d1 -> top, d2->right, d3->bottom, d4->left
          d1_gt, d2_gt, d3_gt, d4_gt, theta_gt = tf.split(value=y_true_geo, num_or_size_splits=5, axis=3)
          d1_pred, d2_pred, d3_pred, d4_pred, theta_pred = tf.split(value=y_pred_geo, num_or_size_splits=5, axis=3)
          area_gt = (d1_gt + d3_gt) * (d2_gt + d4_gt)
          area_pred = (d1_pred + d3_pred) * (d2_pred + d4_pred)
          w_union = tf.minimum(d2_gt, d2_pred) + tf.minimum(d4_gt, d4_pred)
          h_union = tf.minimum(d1_gt, d1_pred) + tf.minimum(d3_gt, d3_pred)
          area_intersect = w_union * h_union
          area_union = area_gt + area_pred - area_intersect
          L_AABB = -tf.log((area_intersect + 1.0)/(area_union + 1.0))
          L_theta = 1 - tf.cos(theta_pred - theta_gt)
          tf.summary.scalar('geometry_AABB', tf.reduce_mean(L_AABB * y_true_cls * training_mask))
          tf.summary.scalar('geometry_theta', tf.reduce_mean(L_theta * y_true_cls * training_mask))
          L_g = L_AABB + 20 * L_theta
  
          return tf.reduce_mean(L_g * y_true_cls * training_mask) + classification_loss
function_tokens: def loss ( self , y_true_cls , y_pred_cls , y_true_geo , y_pred_geo , training_mask ) : classification_loss = self . dice_coefficient ( y_true_cls , y_pred_cls , training_mask ) # scale classification loss to match the iou loss part classification_loss *= 0.01 # d1 -> top, d2->right, d3->bottom, d4->left d1_gt , d2_gt , d3_gt , d4_gt , theta_gt = tf . split ( value = y_true_geo , num_or_size_splits = 5 , axis = 3 ) d1_pred , d2_pred , d3_pred , d4_pred , theta_pred = tf . split ( value = y_pred_geo , num_or_size_splits = 5 , axis = 3 ) area_gt = ( d1_gt + d3_gt ) * ( d2_gt + d4_gt ) area_pred = ( d1_pred + d3_pred ) * ( d2_pred + d4_pred ) w_union = tf . minimum ( d2_gt , d2_pred ) + tf . minimum ( d4_gt , d4_pred ) h_union = tf . minimum ( d1_gt , d1_pred ) + tf . minimum ( d3_gt , d3_pred ) area_intersect = w_union * h_union area_union = area_gt + area_pred - area_intersect L_AABB = - tf . log ( ( area_intersect + 1.0 ) / ( area_union + 1.0 ) ) L_theta = 1 - tf . cos ( theta_pred - theta_gt ) tf . summary . scalar ( 'geometry_AABB' , tf . reduce_mean ( L_AABB * y_true_cls * training_mask ) ) tf . summary . scalar ( 'geometry_theta' , tf . reduce_mean ( L_theta * y_true_cls * training_mask ) ) L_g = L_AABB + 20 * L_theta return tf . reduce_mean ( L_g * y_true_cls * training_mask ) + classification_loss