(self, hparams=None, vocabs=None)
Parameters:
            hparams: Instance of HParams class
            num_tags: Number of output tags
            vocabs: tuple of (word vocab, char vocab, tags vocab). Each is an
                    instance of torchtext.vocab.Vocab.
            NOTE: If word_vocab.vectors is available it will initialize the embeddings
            and with word_vocab.vectors make it non-trainable
Parameters:
            hparams: Instance of HParams class
            num_tags: Number of output tags
            vocabs: tuple of (word vocab, char vocab, tags vocab). Each is an
                    instance of torchtext.vocab.Vocab.
            NOTE: If word_vocab.vectors is available it will initialize the embeddings
            and with word_vocab.vectors make it non-trainable
Parameters : hparams : Instance of HParams class num_tags : Number of output tags vocabs : tuple of ( word vocab char vocab tags vocab ) . Each is an instance of torchtext . vocab . Vocab . NOTE : If word_vocab . vectors is available it will initialize the embeddings and with word_vocab . vectors make it non - trainable
def __init__(self, hparams=None, vocabs=None):
        """
        Parameters:
            hparams: Instance of HParams class
            num_tags: Number of output tags
            vocabs: tuple of (word vocab, char vocab, tags vocab). Each is an
                    instance of torchtext.vocab.Vocab.
            NOTE: If word_vocab.vectors is available it will initialize the embeddings
            and with word_vocab.vectors make it non-trainable
        """
        super(Tagger, self).__init__(hparams)

        if vocabs is None or not isinstance(vocabs, tuple) or len(vocabs) != 3:
            raise ValueError('Must provide vocabs 3-tuple')

        vocab_word, vocab_char, vocab_tags = vocabs
        if vocab_word is None:
            raise ValueError('Must provide vocab_word')
        if vocab_tags is None:
            raise ValueError('Must provide vocab_word')

        self.vocabs = vocabs
        self.vocab_tags = vocab_tags # Needed during eval and prediction
        self.embedding_word = nn.Embedding(len(vocab_word), hparams.embedding_size_word)
        self.embedding_char = None

        if vocab_char is not None and hparams.embedding_size_char > 0:
            self.embedding_char = nn.Embedding(len(vocab_char), hparams.embedding_size_char)
        
        if vocab_word.vectors is not None:
            if hparams.embedding_size_word != vocab_word.vectors.shape[1]:
                raise ValueError('embedding_size should be {} but got {}'
                                .format(vocab_word.vectors.shape[1], 
                                        hparams.embedding_size_word))
            self.embedding_word.weight.data.copy_(vocab_word.vectors)
            self.embedding_word.weight.requires_grad = False
        

        if hparams.use_crf:
            self.output_layer = outputs.CRFOutputLayer(hparams.hidden_size, len(vocab_tags))
        else:
            self.output_layer = outputs.SoftmaxOutputLayer(hparams.hidden_size, len(vocab_tags))
def __init__ ( self , hparams = None , vocabs = None ) : super ( Tagger , self ) . __init__ ( hparams ) if vocabs is None or not isinstance ( vocabs , tuple ) or len ( vocabs ) != 3 : raise ValueError ( 'Must provide vocabs 3-tuple' ) vocab_word , vocab_char , vocab_tags = vocabs if vocab_word is None : raise ValueError ( 'Must provide vocab_word' ) if vocab_tags is None : raise ValueError ( 'Must provide vocab_word' ) self . vocabs = vocabs self . vocab_tags = vocab_tags # Needed during eval and prediction self . embedding_word = nn . Embedding ( len ( vocab_word ) , hparams . embedding_size_word ) self . embedding_char = None if vocab_char is not None and hparams . embedding_size_char > 0 : self . embedding_char = nn . Embedding ( len ( vocab_char ) , hparams . embedding_size_char ) if vocab_word . vectors is not None : if hparams . embedding_size_word != vocab_word . vectors . shape [ 1 ] : raise ValueError ( 'embedding_size should be {} but got {}' . format ( vocab_word . vectors . shape [ 1 ] , hparams . embedding_size_word ) ) self . embedding_word . weight . data . copy_ ( vocab_word . vectors ) self . embedding_word . weight . requires_grad = False if hparams . use_crf : self . output_layer = outputs . CRFOutputLayer ( hparams . hidden_size , len ( vocab_tags ) ) else : self . output_layer = outputs . SoftmaxOutputLayer ( hparams . hidden_size , len ( vocab_tags ) )