GPU单机多卡训练踩坑:单机多卡训练保存的模型,在加载模型时报错【Missing key(s) in state_dict】【训练时候采用的并行计算,应当在预测时也使用并行计算,哪怕只使用单卡】

Missing key(s) in state_dict: "bert_encoder.embeddings.position_ids", "bert_encoder.embeddings.word_embeddings.weight", "bert_encoder.embeddings.position_embeddings.weight", "bert_encoder.embeddings.token_type_embeddings.weight", "bert_encoder.embeddings.LayerNorm.weight", "bert_encoder.embeddings.LayerNorm.bias", "bert_encoder.encoder.layer.0.attention.self.query.weight", "bert_encoder.encoder.layer.0.attention.self.query.bias", "bert_encoder.encoder.layer.0.attention.self.key.weight", "bert_encoder.encoder.layer.0.attention.self.key.bias", "bert_encoder.encoder.layer.0.attention.self.value.weight", "bert_encoder.encoder.layer.0.attention.self.value.bias", "bert_encoder.encoder.layer.0.attention.output.dense.weight", "bert_encoder.encoder.layer.0.attention.output.dense.bias", "bert_encoder.encoder.layer.0.attention.output.LayerNorm.weight", "bert_encoder.encoder.layer.0.attention.output.LayerNorm.bias", "bert_encoder.encoder.layer.0.intermediate.dense.weight", "bert_encoder.encoder.layer.0.intermediate.dense.bias", "bert_encoder.encoder.layer.0.output.dense.weight", "bert_encoder.encoder.layer.0.output.dense.bias", "bert_encoder.encoder.layer.0.output.LayerNorm.weight", "bert_encoder.encoder.layer.0.output.LayerNorm.bias", "bert_encoder.encoder.layer.1.attention.self.query.weight", "bert_encoder.encoder.layer.1.attention.self.query.bias", "bert_encoder.encoder.layer.1.attention.self.key.weight", "bert_encoder.encoder.layer.1.attention.self.key.bias", "bert_encoder.encoder.layer.1.attention.self.value.weight", "bert_encoder.encoder.layer.1.attention.self.value.bias", "bert_encoder.encoder.layer.1.attention.output.dense.weight", "bert_encoder.encoder.layer.1.attention.output.dense.bias", "bert_encoder.encoder.layer.1.attention.output.LayerNorm.weight", "bert_encoder.encoder.layer.1.attention.output.LayerNorm.bias", "bert_encoder.encoder.layer.1.intermediate.dense.weight", "bert_encoder.encoder.layer.1.intermediate.dense.bias", "bert_encoder.encoder.layer.1.output.dense.weight", "bert_encoder.encoder.layer.1.output.dense.bias", "bert_encoder.encoder.layer.1.output.LayerNorm.weight", "bert_encoder.encoder.layer.1.output.LayerNorm.bias", "bert_encoder.encoder.layer.2.attention.self.query.weight", "bert_encoder.encoder.layer.2.attention.self.query.bias", "bert_encoder.encoder.layer.2.attention.self.key.weight", "bert_encoder.encoder.layer.2.attention.self.key.bias", "bert_encoder.encoder.layer.2.attention.self.value.weight", "bert_encoder.encoder.layer.2.attention.self.value.bias", "bert_encoder.encoder.layer.2.attention.output.dense.weight", "bert_encoder.encoder.layer.2.attention.output.dense.bias", "bert_encoder.encoder.layer.2.attention.output.LayerNorm.weight", "bert_encoder.encoder.layer.2.attention.output.LayerNorm.bias", "bert_encoder.encoder.layer.2.intermediate.dense.weight", "bert_encoder.encoder.layer.2.intermediate.dense.bias", "bert_encoder.encoder.layer.2.output.dense.weight", "bert_encoder.encoder.layer.2.output.dense.bias", "bert_encoder.encoder.layer.2.output.LayerNorm.weight", "bert_encoder.encoder.layer.2.output.LayerNorm.bias", "bert_encoder.encoder.layer.3.attention.self.query.weight", "bert_encoder.encoder.layer.3.attention.self.query.bias", "bert_encoder.encoder.layer.3.attention.self.key.weight", "bert_encoder.encoder.layer.3.attention.self.key.bias", "bert_encoder.encoder.layer.3.attention.self.value.weight", "bert_encoder.encoder.layer.3.attention.self.value.bias", "bert_encoder.encoder.layer.3.attention.output.dense.weight", "bert_encoder.encoder.layer.3.attention.output.dense.bias", "bert_encoder.encoder.layer.3.attention.output.LayerNorm.weight", "bert_encoder.encoder.layer.3.attention.output.LayerNorm.bias", "bert_encoder.encoder.layer.3.intermediate.dense.weight", "bert_encoder.encoder.layer.3.intermediate.dense.bias", "bert_encoder.encoder.layer.3.output.dense.weight", "bert_encoder.encoder.layer.3.output.dense.bias", "bert_encoder.encoder.layer.3.output.LayerNorm.weight", "bert_encoder.encoder.layer.3.output.LayerNorm.bias", "bert_encoder.encoder.layer.4.attention.self.query.weight", "bert_encoder.encoder.layer.4.attention.self.query.bias", "bert_encoder.encoder.layer.4.attention.self.key.weight", "bert_encoder.encoder.layer.4.attention.self.key.bias", "bert_encoder.encoder.layer.4.attention.self.value.weight", "bert_encoder.encoder.layer.4.attention.self.value.bias", "bert_encoder.encoder.layer.4.attention.output.dense.weight", "bert_encoder.encoder.layer.4.attention.output.dense.bias", "bert_encoder.encoder.layer.4.attention.output.LayerNorm.weight", "bert_encoder.encoder.layer.4.attention.output.LayerNorm.bias", "bert_encoder.encoder.layer.4.intermediate.dense.weight", "bert_encoder.encoder.layer.4.intermediate.dense.bias", "bert_encoder.encoder.layer.4.output.dense.weight", "bert_encoder.encoder.layer.4.output.dense.bias", "bert_encoder.encoder.layer.4.output.LayerNorm.weight", "bert_encoder.encoder.layer.4.output.LayerNorm.bias", "bert_encoder.encoder.layer.5.attention.self.query.weight", "bert_encoder.encoder.layer.5.attention.self.query.bias", "bert_encoder.encoder.layer.5.attention.self.key.weight", "bert_encoder.encoder.layer.5.attention.self.key.bias", "bert_encoder.encoder.layer.5.attention.self.value.weight", "bert_encoder.encoder.layer.5.attention.self.value.bias", "bert_encoder.encoder.layer.5.attention.output.dense.weight", "bert_encoder.encoder.layer.5.attention.output.dense.bias", "bert_encoder.encoder.layer.5.attention.output.LayerNorm.weight", "bert_encoder.encoder.layer.5.attention.output.LayerNorm.bias", "bert_encoder.encoder.layer.5.intermediate.dense.weight", "bert_encoder.encoder.layer.5.intermediate.dense.bias", "bert_encoder.encoder.layer.5.output.dense.weight", "bert_encoder.encoder.layer.5.output.dense.bias", "bert_encoder.encoder.layer.5.output.LayerNorm.weight", "bert_encoder.encoder.layer.5.output.LayerNorm.bias", "bert_encoder.encoder.layer.6.attention.self.query.weight", "bert_encoder.encoder.layer.6.attention.self.query.bias", "bert_encoder.encoder.layer.6.attention.self.key.weight", "bert_encoder.encoder.layer.6.attention.self.key.bias", "bert_encoder.encoder.layer.6.attention.self.value.weight", "bert_encoder.encoder.layer.6.attention.self.value.bias", "bert_encoder.encoder.layer.6.attention.output.dense.weight", "bert_encoder.encoder.layer.6.attention.output.dense.bias", "bert_encoder.encoder.layer.6.attention.output.LayerNorm.weight", "bert_encoder.encoder.layer.6.attention.output.LayerNorm.bias", "bert_encoder.encoder.layer.6.intermediate.dense.weight", "bert_encoder.encoder.layer.6.intermediate.dense.bias", "bert_encoder.encoder.layer.6.output.dense.weight", "bert_encoder.encoder.layer.6.output.dense.bias", "bert_encoder.encoder.layer.6.output.LayerNorm.weight", "bert_encoder.encoder.layer.6.output.LayerNorm.bias", "bert_encoder.encoder.layer.7.attention.self.query.weight", "bert_encoder.encoder.layer.7.attention.self.query.bias", "bert_encoder.encoder.layer.7.attention.self.key.weight", "bert_encoder.encoder.layer.7.attention.self.key.bias", "bert_encoder.encoder.layer.7.attention.self.value.weight", "bert_encoder.encoder.layer.7.attention.self.value.bias", "bert_encoder.encoder.layer.7.attention.output.dense.weight", "bert_encoder.encoder.layer.7.attention.output.dense.bias", "bert_encoder.encoder.layer.7.attention.output.LayerNorm.weight", "bert_encoder.encoder.layer.7.attention.output.LayerNorm.bias", "bert_encoder.encoder.layer.7.intermediate.dense.weight", "bert_encoder.encoder.layer.7.intermediate.dense.bias", "bert_encoder.encoder.layer.7.output.dense.weight", "bert_encoder.encoder.layer.7.output.dense.bias", "bert_encoder.encoder.layer.7.output.LayerNorm.weight", "bert_encoder.encoder.layer.7.output.LayerNorm.bias", "bert_encoder.encoder.layer.8.attention.self.query.weight", "bert_encoder.encoder.layer.8.attention.self.query.bias", "bert_encoder.encoder.layer.8.attention.self.key.weight", "bert_encoder.encoder.layer.8.attention.self.key.bias", "bert_encoder.encoder.layer.8.attention.self.value.weight", "bert_encoder.encoder.layer.8.attention.self.value.bias", "bert_encoder.encoder.layer.8.attention.output.dense.weight", "bert_encoder.encoder.layer.8.attention.output.dense.bias", "bert_encoder.encoder.layer.8.attention.output.LayerNorm.weight", "bert_encoder.encoder.layer.8.attention.output.LayerNorm.bias", "bert_encoder.encoder.layer.8.intermediate.dense.weight", "bert_encoder.encoder.layer.8.intermediate.dense.bias", "bert_encoder.encoder.layer.8.output.dense.weight", "bert_encoder.encoder.layer.8.output.dense.bias", "bert_encoder.encoder.layer.8.output.LayerNorm.weight", "bert_encoder.encoder.layer.8.output.LayerNorm.bias", "bert_encoder.encoder.layer.9.attention.self.query.weight", "bert_encoder.encoder.layer.9.attention.self.query.bias", "bert_encoder.encoder.layer.9.attention.self.key.weight", "bert_encoder.encoder.layer.9.attention.self.key.bias", "bert_encoder.encoder.layer.9.attention.self.value.weight", "bert_encoder.encoder.layer.9.attention.self.value.bias", "bert_encoder.encoder.layer.9.attention.output.dense.weight", "bert_encoder.encoder.layer.9.attention.output.dense.bias", "bert_encoder.encoder.layer.9.attention.output.LayerNorm.weight", "bert_encoder.encoder.layer.9.attention.output.LayerNorm.bias", "bert_encoder.encoder.layer.9.intermediate.dense.weight", "bert_encoder.encoder.layer.9.intermediate.dense.bias", "bert_encoder.encoder.layer.9.output.dense.weight", "bert_encoder.encoder.layer.9.output.dense.bias", "bert_encoder.encoder.layer.9.output.LayerNorm.weight", "bert_encoder.encoder.layer.9.output.LayerNorm.bias", "bert_encoder.encoder.layer.10.attention.self.query.weight", "bert_encoder.encoder.layer.10.attention.self.query.bias", "bert_encoder.encoder.layer.10.attention.self.key.weight", "bert_encoder.encoder.layer.10.attention.self.key.bias", "bert_encoder.encoder.layer.10.attention.self.value.weight", "bert_encoder.encoder.layer.10.attention.self.value.bias", "bert_encoder.encoder.layer.10.attention.output.dense.weight", "bert_encoder.encoder.layer.10.attention.output.dense.bias", "bert_encoder.encoder.layer.10.attention.output.LayerNorm.weight", "bert_encoder.encoder.layer.10.attention.output.LayerNorm.bias", "bert_encoder.encoder.layer.10.intermediate.dense.weight", "bert_encoder.encoder.layer.10.intermediate.dense.bias", "bert_encoder.encoder.layer.10.output.dense.weight", "bert_encoder.encoder.layer.10.output.dense.bias", "bert_encoder.encoder.layer.10.output.LayerNorm.weight", "bert_encoder.encoder.layer.10.output.LayerNorm.bias", "bert_encoder.encoder.layer.11.attention.self.query.weight", "bert_encoder.encoder.layer.11.attention.self.query.bias", "bert_encoder.encoder.layer.11.attention.self.key.weight", "bert_encoder.encoder.layer.11.attention.self.key.bias", "bert_encoder.encoder.layer.11.attention.self.value.weight", "bert_encoder.encoder.layer.11.attention.self.value.bias", "bert_encoder.encoder.layer.11.attention.output.dense.weight", "bert_encoder.encoder.layer.11.attention.output.dense.bias", "bert_encoder.encoder.layer.11.attention.output.LayerNorm.weight", "bert_encoder.encoder.layer.11.attention.output.LayerNorm.bias", "bert_encoder.encoder.layer.11.intermediate.dense.weight", "bert_encoder.encoder.layer.11.intermediate.dense.bias", "bert_encoder.encoder.layer.11.output.dense.weight", "bert_encoder.encoder.layer.11.output.dense.bias", "bert_encoder.encoder.layer.11.output.LayerNorm.weight", "bert_encoder.encoder.layer.11.output.LayerNorm.bias", "bert_encoder.pooler.dense.weight", "bert_encoder.pooler.dense.bias", "relation_matrix.weight", "relation_matrix.bias", "projection_matrix.weight", "projection_matrix.bias". 
Unexpected key(s) in state_dict: "module.bert_encoder.embeddings.position_ids", "module.bert_encoder.embeddings.word_embeddings.weight", "module.bert_encoder.embeddings.position_embeddings.weight", "module.bert_encoder.embeddings.token_type_embeddings.weight", "module.bert_encoder.embeddings.LayerNorm.weight", "module.bert_encoder.embeddings.LayerNorm.bias", "module.bert_encoder.encoder.layer.0.attention.self.query.weight", "module.bert_encoder.encoder.layer.0.attention.self.query.bias", "module.bert_encoder.encoder.layer.0.attention.self.key.weight", "module.bert_encoder.encoder.layer.0.attention.self.key.bias", "module.bert_encoder.encoder.layer.0.attention.self.value.weight", "module.bert_encoder.encoder.layer.0.attention.self.value.bias", "module.bert_encoder.encoder.layer.0.attention.output.dense.weight", "module.bert_encoder.encoder.layer.0.attention.output.dense.bias", "module.bert_encoder.encoder.layer.0.attention.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.0.attention.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.0.intermediate.dense.weight", "module.bert_encoder.encoder.layer.0.intermediate.dense.bias", "module.bert_encoder.encoder.layer.0.output.dense.weight", "module.bert_encoder.encoder.layer.0.output.dense.bias", "module.bert_encoder.encoder.layer.0.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.0.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.1.attention.self.query.weight", "module.bert_encoder.encoder.layer.1.attention.self.query.bias", "module.bert_encoder.encoder.layer.1.attention.self.key.weight", "module.bert_encoder.encoder.layer.1.attention.self.key.bias", "module.bert_encoder.encoder.layer.1.attention.self.value.weight", "module.bert_encoder.encoder.layer.1.attention.self.value.bias", "module.bert_encoder.encoder.layer.1.attention.output.dense.weight", "module.bert_encoder.encoder.layer.1.attention.output.dense.bias", "module.bert_encoder.encoder.layer.1.attention.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.1.attention.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.1.intermediate.dense.weight", "module.bert_encoder.encoder.layer.1.intermediate.dense.bias", "module.bert_encoder.encoder.layer.1.output.dense.weight", "module.bert_encoder.encoder.layer.1.output.dense.bias", "module.bert_encoder.encoder.layer.1.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.1.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.2.attention.self.query.weight", "module.bert_encoder.encoder.layer.2.attention.self.query.bias", "module.bert_encoder.encoder.layer.2.attention.self.key.weight", "module.bert_encoder.encoder.layer.2.attention.self.key.bias", "module.bert_encoder.encoder.layer.2.attention.self.value.weight", "module.bert_encoder.encoder.layer.2.attention.self.value.bias", "module.bert_encoder.encoder.layer.2.attention.output.dense.weight", "module.bert_encoder.encoder.layer.2.attention.output.dense.bias", "module.bert_encoder.encoder.layer.2.attention.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.2.attention.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.2.intermediate.dense.weight", "module.bert_encoder.encoder.layer.2.intermediate.dense.bias", "module.bert_encoder.encoder.layer.2.output.dense.weight", "module.bert_encoder.encoder.layer.2.output.dense.bias", "module.bert_encoder.encoder.layer.2.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.2.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.3.attention.self.query.weight", "module.bert_encoder.encoder.layer.3.attention.self.query.bias", "module.bert_encoder.encoder.layer.3.attention.self.key.weight", "module.bert_encoder.encoder.layer.3.attention.self.key.bias", "module.bert_encoder.encoder.layer.3.attention.self.value.weight", "module.bert_encoder.encoder.layer.3.attention.self.value.bias", "module.bert_encoder.encoder.layer.3.attention.output.dense.weight", "module.bert_encoder.encoder.layer.3.attention.output.dense.bias", "module.bert_encoder.encoder.layer.3.attention.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.3.attention.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.3.intermediate.dense.weight", "module.bert_encoder.encoder.layer.3.intermediate.dense.bias", "module.bert_encoder.encoder.layer.3.output.dense.weight", "module.bert_encoder.encoder.layer.3.output.dense.bias", "module.bert_encoder.encoder.layer.3.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.3.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.4.attention.self.query.weight", "module.bert_encoder.encoder.layer.4.attention.self.query.bias", "module.bert_encoder.encoder.layer.4.attention.self.key.weight", "module.bert_encoder.encoder.layer.4.attention.self.key.bias", "module.bert_encoder.encoder.layer.4.attention.self.value.weight", "module.bert_encoder.encoder.layer.4.attention.self.value.bias", "module.bert_encoder.encoder.layer.4.attention.output.dense.weight", "module.bert_encoder.encoder.layer.4.attention.output.dense.bias", "module.bert_encoder.encoder.layer.4.attention.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.4.attention.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.4.intermediate.dense.weight", "module.bert_encoder.encoder.layer.4.intermediate.dense.bias", "module.bert_encoder.encoder.layer.4.output.dense.weight", "module.bert_encoder.encoder.layer.4.output.dense.bias", "module.bert_encoder.encoder.layer.4.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.4.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.5.attention.self.query.weight", "module.bert_encoder.encoder.layer.5.attention.self.query.bias", "module.bert_encoder.encoder.layer.5.attention.self.key.weight", "module.bert_encoder.encoder.layer.5.attention.self.key.bias", "module.bert_encoder.encoder.layer.5.attention.self.value.weight", "module.bert_encoder.encoder.layer.5.attention.self.value.bias", "module.bert_encoder.encoder.layer.5.attention.output.dense.weight", "module.bert_encoder.encoder.layer.5.attention.output.dense.bias", "module.bert_encoder.encoder.layer.5.attention.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.5.attention.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.5.intermediate.dense.weight", "module.bert_encoder.encoder.layer.5.intermediate.dense.bias", "module.bert_encoder.encoder.layer.5.output.dense.weight", "module.bert_encoder.encoder.layer.5.output.dense.bias", "module.bert_encoder.encoder.layer.5.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.5.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.6.attention.self.query.weight", "module.bert_encoder.encoder.layer.6.attention.self.query.bias", "module.bert_encoder.encoder.layer.6.attention.self.key.weight", "module.bert_encoder.encoder.layer.6.attention.self.key.bias", "module.bert_encoder.encoder.layer.6.attention.self.value.weight", "module.bert_encoder.encoder.layer.6.attention.self.value.bias", "module.bert_encoder.encoder.layer.6.attention.output.dense.weight", "module.bert_encoder.encoder.layer.6.attention.output.dense.bias", "module.bert_encoder.encoder.layer.6.attention.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.6.attention.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.6.intermediate.dense.weight", "module.bert_encoder.encoder.layer.6.intermediate.dense.bias", "module.bert_encoder.encoder.layer.6.output.dense.weight", "module.bert_encoder.encoder.layer.6.output.dense.bias", "module.bert_encoder.encoder.layer.6.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.6.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.7.attention.self.query.weight", "module.bert_encoder.encoder.layer.7.attention.self.query.bias", "module.bert_encoder.encoder.layer.7.attention.self.key.weight", "module.bert_encoder.encoder.layer.7.attention.self.key.bias", "module.bert_encoder.encoder.layer.7.attention.self.value.weight", "module.bert_encoder.encoder.layer.7.attention.self.value.bias", "module.bert_encoder.encoder.layer.7.attention.output.dense.weight", "module.bert_encoder.encoder.layer.7.attention.output.dense.bias", "module.bert_encoder.encoder.layer.7.attention.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.7.attention.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.7.intermediate.dense.weight", "module.bert_encoder.encoder.layer.7.intermediate.dense.bias", "module.bert_encoder.encoder.layer.7.output.dense.weight", "module.bert_encoder.encoder.layer.7.output.dense.bias", "module.bert_encoder.encoder.layer.7.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.7.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.8.attention.self.query.weight", "module.bert_encoder.encoder.layer.8.attention.self.query.bias", "module.bert_encoder.encoder.layer.8.attention.self.key.weight", "module.bert_encoder.encoder.layer.8.attention.self.key.bias", "module.bert_encoder.encoder.layer.8.attention.self.value.weight", "module.bert_encoder.encoder.layer.8.attention.self.value.bias", "module.bert_encoder.encoder.layer.8.attention.output.dense.weight", "module.bert_encoder.encoder.layer.8.attention.output.dense.bias", "module.bert_encoder.encoder.layer.8.attention.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.8.attention.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.8.intermediate.dense.weight", "module.bert_encoder.encoder.layer.8.intermediate.dense.bias", "module.bert_encoder.encoder.layer.8.output.dense.weight", "module.bert_encoder.encoder.layer.8.output.dense.bias", "module.bert_encoder.encoder.layer.8.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.8.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.9.attention.self.query.weight", "module.bert_encoder.encoder.layer.9.attention.self.query.bias", "module.bert_encoder.encoder.layer.9.attention.self.key.weight", "module.bert_encoder.encoder.layer.9.attention.self.key.bias", "module.bert_encoder.encoder.layer.9.attention.self.value.weight", "module.bert_encoder.encoder.layer.9.attention.self.value.bias", "module.bert_encoder.encoder.layer.9.attention.output.dense.weight", "module.bert_encoder.encoder.layer.9.attention.output.dense.bias", "module.bert_encoder.encoder.layer.9.attention.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.9.attention.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.9.intermediate.dense.weight", "module.bert_encoder.encoder.layer.9.intermediate.dense.bias", "module.bert_encoder.encoder.layer.9.output.dense.weight", "module.bert_encoder.encoder.layer.9.output.dense.bias", "module.bert_encoder.encoder.layer.9.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.9.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.10.attention.self.query.weight", "module.bert_encoder.encoder.layer.10.attention.self.query.bias", "module.bert_encoder.encoder.layer.10.attention.self.key.weight", "module.bert_encoder.encoder.layer.10.attention.self.key.bias", "module.bert_encoder.encoder.layer.10.attention.self.value.weight", "module.bert_encoder.encoder.layer.10.attention.self.value.bias", "module.bert_encoder.encoder.layer.10.attention.output.dense.weight", "module.bert_encoder.encoder.layer.10.attention.output.dense.bias", "module.bert_encoder.encoder.layer.10.attention.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.10.attention.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.10.intermediate.dense.weight", "module.bert_encoder.encoder.layer.10.intermediate.dense.bias", "module.bert_encoder.encoder.layer.10.output.dense.weight", "module.bert_encoder.encoder.layer.10.output.dense.bias", "module.bert_encoder.encoder.layer.10.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.10.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.11.attention.self.query.weight", "module.bert_encoder.encoder.layer.11.attention.self.query.bias", "module.bert_encoder.encoder.layer.11.attention.self.key.weight", "module.bert_encoder.encoder.layer.11.attention.self.key.bias", "module.bert_encoder.encoder.layer.11.attention.self.value.weight", "module.bert_encoder.encoder.layer.11.attention.self.value.bias", "module.bert_encoder.encoder.layer.11.attention.output.dense.weight", "module.bert_encoder.encoder.layer.11.attention.output.dense.bias", "module.bert_encoder.encoder.layer.11.attention.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.11.attention.output.LayerNorm.bias", "module.bert_encoder.encoder.layer.11.intermediate.dense.weight", "module.bert_encoder.encoder.layer.11.intermediate.dense.bias", "module.bert_encoder.encoder.layer.11.output.dense.weight", "module.bert_encoder.encoder.layer.11.output.dense.bias", "module.bert_encoder.encoder.layer.11.output.LayerNorm.weight", "module.bert_encoder.encoder.layer.11.output.LayerNorm.bias", "module.bert_encoder.pooler.dense.weight", "module.bert_encoder.pooler.dense.bias", "module.relation_matrix.weight", "module.relation_matrix.bias", "module.projection_matrix.weight", "module.projection_matrix.bias". 

因为训练时候采用的并行计算,导致微调后的模型文件key中会包含"module"关键字,再次加载时在单卡做预测就出错了。

应当在预测时也使用并行计算,哪怕只使用单卡,也要DataParallel一下

model = TitleClassifier(len(class_names))  
model = model.cuda()
model = nn.DataParallel(model)
model.load_state_dict(torch.load("best_model_state.bin"))



参考资料:
GPU单机多卡训练踩的坑

你可能感兴趣的:(AI/模型训练,深度学习,人工智能,机器学习)