【问题标题】:How to optimize fine-tuned BERT's model size in TensorFlow 2.0?如何在 TensorFlow 2.0 中优化微调后的 BERT 模型大小?
【发布时间】:2020-09-16 00:29:40
【问题描述】:

在对 BERT 进行分类微调后,模型大小约为 1.3GB,而预训练模型大小约为 400MB。发生这种情况是由于与模型一起保存的与 Adam 相关的其他变量,并且可以在保存时删除,如 TensorFlow 1.x 的https://github.com/google-research/bert/issues/99 中所述。

如何在 TensorFlow 2.x 中做到这一点?

【问题讨论】:

    标签: tensorflow2.0 text-classification bert-language-model


    【解决方案1】:

    找到了解决办法。训练模型的save() 方法有一个参数include_optimizer,默认为True。将其设置为False 不会保存优化器的状态,保存的模型文件与预训练文件相当。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-21
      • 2021-07-22
      • 2020-05-23
      • 2020-09-17
      • 1970-01-01
      • 2021-08-19
      • 2020-06-03
      • 1970-01-01
      相关资源
      最近更新 更多