コード例 #1
0
    def load_model(path):
        """
        Load an existing SequenceTagger model (with weights) from HDF5 file.

        :param path: String. The path to the pre-defined model.
        :return: NER.
        """
        labor = chunker.SequenceTagger(use_cudnn=False)
        model = TextKerasModel._load_model(labor, path)
        model.__class__ = SequenceTagger
        return model
コード例 #2
0
 def __init__(self,
              num_pos_labels,
              num_chunk_labels,
              word_vocab_size,
              char_vocab_size=None,
              word_length=12,
              feature_size=100,
              dropout=0.2,
              classifier='softmax',
              optimizer=None):
     classifier = classifier.lower()
     assert classifier in ['softmax', 'crf'
                           ], "classifier should be either softmax or crf"
     super(SequenceTagger,
           self).__init__(chunker.SequenceTagger(use_cudnn=False),
                          vocabulary_size=word_vocab_size,
                          num_pos_labels=num_pos_labels,
                          num_chunk_labels=num_chunk_labels,
                          char_vocab_size=char_vocab_size,
                          max_word_len=word_length,
                          feature_size=feature_size,
                          dropout=dropout,
                          classifier=classifier,
                          optimizer=optimizer)
コード例 #3
0
 def load_model(path):
     labor = chunker.SequenceTagger(use_cudnn=False)
     model = TextKerasModel._load_model(labor, path)
     model.__class__ = SequenceTagger
     return model