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 #19

Open
779257747 opened this issue Mar 20, 2024 · 3 comments

Comments

@779257747
Copy link

image
请问这是transformer版本库导致的问题吗

@king-yyf
Copy link
Owner

king-yyf commented Apr 1, 2024

可能是的,我自己本地是正常的,看看 https://stackoverflow.com/questions/65082243/dropout-argument-input-position-1-must-be-tensor-not-str-when-using-bert 有没有能参考的。

@yuxinwuchn
Copy link

bert_lstm_crf文件43行

embeds, _ = self.word_embeds(sentence, attention_mask=attention_mask)

改成

embeds, _ = self.word_embeds(sentence, attention_mask=attention_mask, return_dict=False)

crf文件134行

cur_bp.masked_fill_(mask[idx].view(batch_size, 1).expand(batch_size, tag_size), 0)

改成

cur_bp.masked_fill_(mask[idx].view(batch_size, 1).expand(batch_size, tag_size).bool(), 0)

@BobBranson
Copy link

bert_lstm_crf文件43行

embeds, _ = self.word_embeds(sentence, attention_mask=attention_mask)

改成

embeds, _ = self.word_embeds(sentence, attention_mask=attention_mask, return_dict=False)

crf文件134行

cur_bp.masked_fill_(mask[idx].view(batch_size, 1).expand(batch_size, tag_size), 0)

改成

cur_bp.masked_fill_(mask[idx].view(batch_size, 1).expand(batch_size, tag_size).bool(), 0)

可以的

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

4 participants