train_loss, train_acc = train(model, sentiment_train_loader, optimizer, criterion, device) File "D:/p_got an u">
当前位置:   article > 正文

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

got an unexpected keyword argument 'laber

在调用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'
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

找到报错的行数

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

改为如下代码 正常运行

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

前后变化将label改为了labels

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/286479?site
推荐阅读
相关标签
  

闽ICP备14008679号