king-yyf/CMeKG_tools

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

779257747 opened this issue · 3 comments

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

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)

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)

可以的