代码报错|报错(TypeError forward() got an unexpected keyword argument)

已解决:TypeError: forward() got an unexpected keyword argument 【代码报错|报错(TypeError forward() got an unexpected keyword argument)】报错:TypeError: forward() got an unexpected keyword argument
问题一 代码报错|报错(TypeError forward() got an unexpected keyword argument)
文章图片

解决方案:

sequence_output, pooled_output = self.bert_model(input_ids=token_ids, token_type_ids=token_type_ids, attention_mask=attention_mask,return_dict=False)

改为:
sequence_output, pooled_output = self.bert_model(input_ids=token_ids, token_type_ids=token_type_ids, attention_mask=attention_mask)

问题二 代码报错|报错(TypeError forward() got an unexpected keyword argument)
文章图片

解决方案:
# 将 self.bert_model中的超参数改为labels=None,或者是去掉labels,选择默认

    推荐阅读