macanv / BERT-BiLSTM-CRF-NER

Tensorflow solution of NER task Using BiLSTM-CRF model with Google BERT Fine-tuning And private Server services
https://github.com/macanv/BERT-BiLSMT-CRF-NER
4.68k stars 1.25k forks source link

如果想保存每次训练表现最好的那一个step的模型,该如何操作? #303

Open wby1999 opened 4 years ago

macanv commented 4 years ago

简单说三种: 1.写hook,放到estimator中 2.使用bert4keras 写hook

  1. 使用sess.run这种低阶api,以前怎么保存,现在还是一样。

如果你认为loss不再下降的时候,就是最好的模型,可以直接参考代码中的early stop 的使用(具体使用,参考官方文档。)。

currenttime commented 4 years ago

tf1.14中改为:tf.estimator.experimental.stop_if_no_decrease_hook 其他参数不变,然后无论怎么调整max_steps_without_decrease根本不会提前停止啊,好像没起作用。

Heaven-zhw commented 4 years ago

tf1.14中改为:tf.estimator.experimental.stop_if_no_decrease_hook 其他参数不变,然后无论怎么调整max_steps_without_decrease根本不会提前停止啊,好像没起作用。

我这里会,我设的1000,原本要训练9900step,现在5001step就停下来了