bert4keras icon indicating copy to clipboard operation
bert4keras copied to clipboard

Fine -tuning 可以正常加载,Pretraining 模型加载报错。

Open Jhangsy opened this issue 4 years ago • 2 comments

问题说明

你好,苏神! 这个模型 fine-tuning 可以正常加载,但是 pretraining 加载会报错如下,是这个预训练模型变量没有保留最后一层 mlm 导致的吗?

基本信息

  • 你加载的预训练模型: 加载的是 https://github.com/CLUEbenchmark/CLUEPretrainedModels 的 Roberta-Tiny-Clue 模型

输出信息

tensorflow.python.framework.errors_impl.NotFoundError: Key cls/predictions/transform/dense/kernel not found in checkpoint

Jhangsy avatar Jun 08 '21 07:06 Jhangsy

是的,CLUE的模型都没有保留mlm权重,不知为何。

最新版的bert4keras,你可以在build_transformer_model的时候传入ignore_invalid_weights=True来忽略这个错误。

bojone avatar Jun 09 '21 03:06 bojone

是的,CLUE的模型都没有保留mlm权重,不知为何。

最新版的bert4keras,你可以在build_transformer_model的时候传入ignore_invalid_weights=True来忽略这个错误。

感谢苏神。

如果 pretraining 选择 ignore_invalid_weights=True 是通过用随机数值代替缺失的权重吗?这种方式继续预训练后的模型应该比保留 mlm 的权重的模型效果要差吧?

Jhangsy avatar Jun 09 '21 09:06 Jhangsy