コード例 #1
0
 def __init__(self, model, **kwargs):
     super(TaggerTrainerTf, self).__init__()
     self.loss = model.create_loss()
     self.model = model
     span_type = kwargs.get('span_type', 'iob')
     self.evaluator = TaggerEvaluatorTf(model, span_type)
     self.global_step, self.train_op = optimizer(self.loss, **kwargs)
コード例 #2
0
ファイル: train.py プロジェクト: switchfootsid/baseline
 def __init__(self, model, **kwargs):
     super(Seq2SeqTrainerTf, self).__init__()
     self.sess = model.sess
     self.loss = model.create_loss()
     self.test_loss = model.create_test_loss()
     self.model = model
     self.global_step, self.train_op = optimizer(self.loss, **kwargs)
コード例 #3
0
ファイル: train.py プロジェクト: switchfootsid/baseline
 def __init__(self, model, **kwargs):
     super(ClassifyTrainerTf, self).__init__()
     self.sess = model.sess
     self.loss = model.create_loss()
     self.test_loss = model.create_test_loss()
     self.model = model
     self.global_step, self.train_op = optimizer(
         self.loss, colocate_gradients_with_ops=True, **kwargs)
コード例 #4
0
 def __init__(self, model, **kwargs):
     super(ClassifyTrainerTf, self).__init__()
     self.sess = model.sess
     self.loss = model.create_loss()
     self.test_loss = model.create_test_loss()
     self.model = model
     self.global_step, train_op = optimizer(
         self.loss, colocate_gradients_with_ops=True, **kwargs)
     decay = kwargs.get('ema_decay', None)
     if decay is not None:
         self.ema = True
         ema_op, self.ema_load, self.ema_restore = _add_ema(
             model, float(decay))
         with tf.control_dependencies([ema_op]):
             self.train_op = tf.identity(train_op)
     else:
         self.ema = False
         self.train_op = train_op
コード例 #5
0
 def __init__(self, model, **kwargs):
     super(TaggerTrainerTf, self).__init__()
     self.loss = model.create_loss()
     self.model = model
     self.evaluator = TaggerEvaluatorTf(model)
     self.global_step, self.train_op = optimizer(self.loss, **kwargs)