Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: dropout(): argument 'input' (position 1) must be Tensor, not str #11

Open
luohm111 opened this issue Mar 9, 2021 · 1 comment

Comments

@luohm111
Copy link

luohm111 commented Mar 9, 2021

您好,能请教一个问题吗?我在运行python ptbert.py的时候报了上面的错,显示错误在pooled_output = self.dropout(pooled_output)这一行,打印出pooled_output是'pooler_output'这个东西,是个str不是tensor,这就很奇怪了,_, pooled_output = self.bert(input_ids, None, input_mask),为什么bert出来的pooled_output就是'pooler_output'呢?我不知道是哪里错了,还望能指点下吗?非常感谢大佬!

@bianximo
Copy link

新版transformers BertModel默认返回BaseModelOutputWithPoolingAndCrossAttentions了,改成
pooled_output = self.bert(input_ids, attention_mask=input_mask).pooler_output就好了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants