Exemplo n.º 1
0
        def get_learner(self):
            learner_selection = input_json['learner']

            if learner_selection == 'CRF':
                return "CRF_l2sgd", get_crf()
            if learner_selection == 'BiLSTM':
                return 'BiLSTM+CRF', BiLstmCrfLearner(self.word_embeddings,
                                                      self.cuda_device)
            if learner_selection == 'BERT':
                learner = BertLearner(self.cuda_device,
                                      pretrained_model=self.pretrained_model,
                                      batch_size=self.batch_size,
                                      learning_rate=self.learning_rate,
                                      epochs=self.epochs,
                                      using_crf=self.using_crf)
                return 'BERT', learner
            else:
                raise ValueError(
                    f"'learner' must be 'CRF', 'BiLSTM', or 'BERT', but is {learner_selection}"
                )
 def get_learner(self):
     return "CRF_l2sgd", get_crf()