本文整理匯總了Python中bert.optimization.create_optimizer方法的典型用法代碼示例。如果您正苦於以下問題:Python optimization.create_optimizer方法的具體用法?Python optimization.create_optimizer怎麽用?Python optimization.create_optimizer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類bert.optimization
的用法示例。
在下文中一共展示了optimization.create_optimizer方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: tune
# 需要導入模塊: from bert import optimization [as 別名]
# 或者: from bert.optimization import create_optimizer [as 別名]
def tune(self):
global_step = tf.train.get_or_create_global_step()
tf.logging.info("num_train_steps: " + str(self.num_train_steps))
tf.logging.info("num_warmup_steps: " + str(self.num_warmup_steps))
train_op = create_optimizer(self.loss, self.learning_rate, self.num_train_steps, self.num_warmup_steps, use_tpu=False)
output_feed = [train_op, global_step, self.logits, self.loss]
restore_vars = [v for v in tf.trainable_variables() if "bert" in v.name]
sess = tf.Session()
sess.run(tf.global_variables_initializer())
tf.train.Saver(restore_vars).restore(sess, self.pretrain_model_fname)
saver = tf.train.Saver(max_to_keep=1)
self.train(sess, saver, global_step, output_feed)