TypeError: forward() got an unexpected keyword argument ‘label‘

在调用bert 模型是遇到如下报错信息:

Traceback (most recent call last):
  File "D:/program/PyChramWorkspace/CS224N/fine tune/TestSA.py", line 131, in <module>
    train_loss, train_acc = train(model, sentiment_train_loader, optimizer, criterion, device)
  File "D:/program/PyChramWorkspace/CS224N/fine tune/TestSA.py", line 83, in train
    output = model(**tokenized_text, label=label)
  File "D:\program\Anaconda3\lib\site-packages\torch\nn\modules\module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
TypeError: forward() got an unexpected keyword argument 'label'

找到报错的行数

	output = model(**tokenized_text, label=label)

改为如下代码 正常运行

	output = model(**tokenized_text, labels=label)

前后变化将label改为了labels

在这里插入图片描述

你可能感兴趣的:(python,bug,网络,bert,深度学习)