Python: BERT Error - Some weights of the model checkpoint at were not used when initializing BertMod

在调用transformers预训练模型库时出现以下信息:

Some weights of the model checkpoint at bert-base-multilingual-cased were not used when initializing BertForTokenClassification_: ['cls.predictions.transform.LayerNorm.weight', 'cls.predictions.transform.dense.weight', 'cls.predictions.transform.dense.bias', 'cls.predictions.bias', 'cls.seq_relationship.bias', 'cls.predictions.decoder.weight', 'cls.predictions.transform.LayerNorm.bias', 'cls.seq_relationship.weight']
- This IS expected if you are initializing BertForTokenClassification_ from the checkpoint of a model trained on another task or with another architecture (e.g. initializing a BertForSequenceClassification model from a BertForPreTraining model).
- This IS NOT expected if you are initializing BertForTokenClassification_ from the checkpoint of a model that you expect to be exactly identical (initializing a BertForSequenceClassification model from a BertForSequenceClassification model).
Some weights of BertForTokenClassification_ were not initialized from the model checkpoint at bert-base-multilingual-cased and are newly initialized: ['classifier.weight', 'classifier.bias']
You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.

解决方法:

这不是一个错误,但这个警告意味着在你的训练过程中,你没有使用pooler来计算损失。因此,如果是这种情况,则无需担心。

可以通过以下方式设置不显示此警告

from transformers import logging

logging.set_verbosity_warning()

或者在在训练后加载模型,则不会看到此错误消息

你可能感兴趣的:(pytorch,python,bert,自然语言处理)