modules/loss.py
def hamming_loss(c: Tensor, y: Tensor, threshold=0.8) -> Tensor:
    """
    compute the hamming loss (refer to the origin paper)
    :param c: size: batch_size * n_labels, output of NN
    :param y: size: batch_size * n_labels, target
    :return: Scalar
    """
    assert 0 <= threshold <= 1, "threshold should be between 0 and 1"
    p, q = c.size()
    return 1.0 / (p * q) * (((c > threshold).int() - y) != 0).float().sum()

    compute the hamming loss (refer to the origin paper)
    :param c: size: batch_size * n_labels, output of NN
    :param y: size: batch_size * n_labels, target
    :return: Scalar
    
compute the hamming loss (refer to the origin paper)
compute the hamming loss ( refer to the origin paper )
def hamming_loss(c: Tensor, y: Tensor, threshold=0.8) -> Tensor:
    assert 0 <= threshold <= 1, "threshold should be between 0 and 1"
    p, q = c.size()
    return 1.0 / (p * q) * (((c > threshold).int() - y) != 0).float().sum()
def hamming_loss ( c : Tensor , y : Tensor , threshold = 0.8 ) -> Tensor : assert 0 <= threshold <= 1 , "threshold should be between 0 and 1" p , q = c . size ( ) return 1.0 / ( p * q ) * ( ( ( c > threshold ) . int ( ) - y ) != 0 ) . float ( ) . sum ( )
compute the hamming loss (refer to the origin paper)
compute the hamming loss ( refer to the origin paper )
"""
    compute the hamming loss (refer to the origin paper)
    :param c: size: batch_size * n_labels, output of NN
    :param y: size: batch_size * n_labels, target
    :return: Scalar
    """
None
c
Tensor
batch_size * n_labels, output of NN
batch_size * n_labels output of NN
y
Tensor
batch_size * n_labels, target
batch_size * n_labels target
threshold