(self, output, target)
Args:
            output (Tensor): NxK tensor that for each of the N examples
                indicates the probability of the example belonging to each of
                the K classes, according to the model. The probabilities should
                sum to one over all classes
            target (Tensor): binary NxK tensort that encodes which of the K
                classes are associated with the N-th input
                    (eg: a row [0, 1, 0, 1] indicates that the example is
                         associated with classes 2 and 4)
            weight (optional, Tensor): Nx1 tensor representing the weight for
                each example (each weight > 0)
Args:
            output (Tensor): NxK tensor that for each of the N examples
                indicates the probability of the example belonging to each of
                the K classes, according to the model. The probabilities should
                sum to one over all classes
            target (Tensor): binary NxK tensort that encodes which of the K
                classes are associated with the N-th input
                    (eg: a row [0, 1, 0, 1] indicates that the example is
                         associated with classes 2 and 4)
            weight (optional, Tensor): Nx1 tensor representing the weight for
                each example (each weight > 0)
Args : output ( Tensor ) : NxK tensor that for each of the N examples indicates the probability of the example belonging to each of the K classes according to the model . The probabilities should sum to one over all classes target ( Tensor ) : binary NxK tensort that encodes which of the K classes are associated with the N - th input ( eg : a row [ 0 1 0 1 ] indicates that the example is associated with classes 2 and 4 ) weight ( optional Tensor ) : Nx1 tensor representing the weight for each example ( each weight > 0 )
def add(self, output, target):
        """
        Args:
            output (Tensor): NxK tensor that for each of the N examples
                indicates the probability of the example belonging to each of
                the K classes, according to the model. The probabilities should
                sum to one over all classes
            target (Tensor): binary NxK tensort that encodes which of the K
                classes are associated with the N-th input
                    (eg: a row [0, 1, 0, 1] indicates that the example is
                         associated with classes 2 and 4)
            weight (optional, Tensor): Nx1 tensor representing the weight for
                each example (each weight > 0)
        """
        if not torch.is_tensor(output):
            output = torch.from_numpy(output)
        if not torch.is_tensor(target):
            target = torch.from_numpy(target)

        if output.dim() == 1:
            output = output.view(-1, 1)
        else:
            assert output.dim() == 2, \
                'wrong output size (should be 1D or 2D with one column \
                per class)'
        if target.dim() == 1:
            target = target.view(-1, 1)
        else:
            assert target.dim() == 2, \
                'wrong target size (should be 1D or 2D with one column \
                per class)'
        if self.scores.numel() > 0:
            assert target.size(1) == self.targets.size(1), \
                'dimensions for output should match previously added examples.'

        # make sure storage is of sufficient size
        if self.scores.storage().size() < self.scores.numel() + output.numel():
            new_size = math.ceil(self.scores.storage().size() * 1.5)
            self.scores.storage().resize_(int(new_size + output.numel()))
            self.targets.storage().resize_(int(new_size + output.numel()))

        # store scores and targets
        offset = self.scores.size(0) if self.scores.dim() > 0 else 0
        self.scores.resize_(offset + output.size(0), output.size(1))
        self.targets.resize_(offset + target.size(0), target.size(1))
        self.scores.narrow(0, offset, output.size(0)).copy_(output)
        self.targets.narrow(0, offset, target.size(0)).copy_(target)
def add ( self , output , target ) : if not torch . is_tensor ( output ) : output = torch . from_numpy ( output ) if not torch . is_tensor ( target ) : target = torch . from_numpy ( target ) if output . dim ( ) == 1 : output = output . view ( - 1 , 1 ) else : assert output . dim ( ) == 2 , 'wrong output size (should be 1D or 2D with one column \
                per class)' if target . dim ( ) == 1 : target = target . view ( - 1 , 1 ) else : assert target . dim ( ) == 2 , 'wrong target size (should be 1D or 2D with one column \
                per class)' if self . scores . numel ( ) > 0 : assert target . size ( 1 ) == self . targets . size ( 1 ) , 'dimensions for output should match previously added examples.' # make sure storage is of sufficient size if self . scores . storage ( ) . size ( ) < self . scores . numel ( ) + output . numel ( ) : new_size = math . ceil ( self . scores . storage ( ) . size ( ) * 1.5 ) self . scores . storage ( ) . resize_ ( int ( new_size + output . numel ( ) ) ) self . targets . storage ( ) . resize_ ( int ( new_size + output . numel ( ) ) ) # store scores and targets offset = self . scores . size ( 0 ) if self . scores . dim ( ) > 0 else 0 self . scores . resize_ ( offset + output . size ( 0 ) , output . size ( 1 ) ) self . targets . resize_ ( offset + target . size ( 0 ) , target . size ( 1 ) ) self . scores . narrow ( 0 , offset , output . size ( 0 ) ) . copy_ ( output ) self . targets . narrow ( 0 , offset , target . size ( 0 ) ) . copy_ ( target )