src/fingerflow/matcher/VerifyNet/utils.py
def verify_net_loss(margin):
    """Provides 'constrastive_loss' an enclosing scope with variable 'margin'.

    Arguments:
        margin: Integer, defines the baseline for distance for which pairs
                should be classified as dissimilar. - normally used value is 1.

    Returns:
        'constrastive_loss' function with data ('margin') attached.
    """

    def contrastive_loss(y_true, y_pred):
        """Calculates the constrastive loss.

        Arguments:
            y_true: List of labels, each label is of type float32.
            y_pred: List of predictions of same length as of y_true,
                    each label is of type float32.

        Returns:
            A tensor containing constrastive loss as floating point value.
        """

        square_pred = tf.math.square(y_pred)
        margin_square = tf.math.square(tf.math.maximum(margin - (y_pred), 0))

        return tf.math.reduce_mean((1 - y_true) * square_pred + (y_true) * margin_square)

    return contrastive_loss
Provides 'constrastive_loss' an enclosing scope with variable 'margin'.

    Arguments:
        margin: Integer, defines the baseline for distance for which pairs
                should be classified as dissimilar. - normally used value is 1.

    Returns:
        'constrastive_loss' function with data ('margin') attached.
    
Provides 'constrastive_loss' an enclosing scope with variable 'margin'.
Provides ' constrastive_loss ' an enclosing scope with variable ' margin ' .
def verify_net_loss(margin):
    def contrastive_loss(y_true, y_pred):
        square_pred = tf.math.square(y_pred)
        margin_square = tf.math.square(tf.math.maximum(margin - (y_pred), 0))
        return tf.math.reduce_mean((1 - y_true) * square_pred + (y_true) * margin_square)
    return contrastive_loss
def verify_net_loss ( margin ) : def contrastive_loss ( y_true , y_pred ) : """Calculates the constrastive loss.

        Arguments:
            y_true: List of labels, each label is of type float32.
            y_pred: List of predictions of same length as of y_true,
                    each label is of type float32.

        Returns:
            A tensor containing constrastive loss as floating point value.
        """ square_pred = tf . math . square ( y_pred ) margin_square = tf . math . square ( tf . math . maximum ( margin - ( y_pred ) , 0 ) ) return tf . math . reduce_mean ( ( 1 - y_true ) * square_pred + ( y_true ) * margin_square ) return contrastive_loss
Provides 'constrastive_loss' an enclosing scope with variable 'margin'.
Provides ' constrastive_loss ' an enclosing scope with variable ' margin ' .
"""Provides 'constrastive_loss' an enclosing scope with variable 'margin'.

    Arguments:
        margin: Integer, defines the baseline for distance for which pairs
                should be classified as dissimilar. - normally used value is 1.

    Returns:
        'constrastive_loss' function with data ('margin') attached.
    """ """Calculates the constrastive loss.

        Arguments:
            y_true: List of labels, each label is of type float32.
            y_pred: List of predictions of same length as of y_true,
                    each label is of type float32.

        Returns:
            A tensor containing constrastive loss as floating point value.
        """
'constrastive_loss' function with data ('margin') attached.
' constrastive_loss ' function with data ( ' margin ' ) attached .
margin
Integer, defines the baseline for distance for which pairs
should be classified as dissimilar. - normally used value is 1.
Integer defines the baseline for distance for which pairs should be classified as dissimilar . - normally used value is 1 .