(self, feats, tags)
return -log_probability.mean()
Computes negative log likelihood between features and tags.
        Essentially difference between individual sequence scores and 
        sum of all possible sequence scores (partition function)
        Parameters:
            feats: Input features [batch size, sequence length, number of tags]
            tags: Target tag indices [batch size, sequence length]. Should be between
                    0 and num_tags
        Returns:
            Negative log likelihood [a scalar]
Computes negative log likelihood between features and tags.
        Essentially difference between individual sequence scores and 
        sum of all possible sequence scores (partition function)
        Parameters:
            feats: Input features [batch size, sequence length, number of tags]
            tags: Target tag indices [batch size, sequence length]. Should be between
                    0 and num_tags
        Returns:
            Negative log likelihood [a scalar]
Computes negative log likelihood between features and tags . Essentially difference between individual sequence scores and sum of all possible sequence scores ( partition function ) Parameters : feats : Input features [ batch size sequence length number of tags ] tags : Target tag indices [ batch size sequence length ] . Should be between 0 and num_tags Returns : Negative log likelihood [ a scalar ]
def loss(self, feats, tags):
        """
        Computes negative log likelihood between features and tags.
        Essentially difference between individual sequence scores and 
        sum of all possible sequence scores (partition function)
        Parameters:
            feats: Input features [batch size, sequence length, number of tags]
            tags: Target tag indices [batch size, sequence length]. Should be between
                    0 and num_tags
        Returns:
            Negative log likelihood [a scalar] 
        """
        # Shape checks
        if len(feats.shape) != 3:
            raise ValueError("feats must be 3-d got {}-d".format(feats.shape))

        if len(tags.shape) != 2:
            raise ValueError('tags must be 2-d but got {}-d'.format(tags.shape))

        if feats.shape[:2] != tags.shape:
            raise ValueError('First two dimensions of feats and tags must match')

        sequence_score = self._sequence_score(feats, tags)
        partition_function = self._partition_function(feats)
        log_probability = sequence_score - partition_function

        # -ve of l()
        # Average across batch
        return -log_probability.mean()
def loss ( self , feats , tags ) : # Shape checks if len ( feats . shape ) != 3 : raise ValueError ( "feats must be 3-d got {}-d" . format ( feats . shape ) ) if len ( tags . shape ) != 2 : raise ValueError ( 'tags must be 2-d but got {}-d' . format ( tags . shape ) ) if feats . shape [ : 2 ] != tags . shape : raise ValueError ( 'First two dimensions of feats and tags must match' ) sequence_score = self . _sequence_score ( feats , tags ) partition_function = self . _partition_function ( feats ) log_probability = sequence_score - partition_function # -ve of l() # Average across batch return - log_probability . mean ( )