bert_distill icon indicating copy to clipboard operation
bert_distill copied to clipboard

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

Open luohm111 opened this issue 4 years ago • 1 comments

您好,能请教一个问题吗?我在运行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'呢?我不知道是哪里错了,还望能指点下吗?非常感谢大佬!

luohm111 avatar Mar 09 '21 06:03 luohm111

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

bianximo avatar Mar 27 '21 07:03 bianximo