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

AttributeError: 'str' object has no attribute 'detach' #5

Closed
FLxuRu opened this issue Dec 23, 2020 · 1 comment
Closed

AttributeError: 'str' object has no attribute 'detach' #5

FLxuRu opened this issue Dec 23, 2020 · 1 comment

Comments

@FLxuRu
Copy link

FLxuRu commented Dec 23, 2020

encoder.py这个文件中的vec是str类型,vec.detach()这样写会报错,请问作者这里是不是去掉detach()

def get_bert_vec(self, text, text_mask, text_pos=None):
if text_pos is None:
_, _, text_vecs = self.bert(text, text_mask)
else:
_, _, text_vecs = self.bert(text, text_mask, position_ids=text_pos)
text_vecs = list(text_vecs)
if self.detach_ptm_flag:
for i, vec in enumerate(text_vecs):
text_vecs[i] = vec.detach()
return text_vecs

@BaberMuyu
Copy link
Owner

这是transformers的版本问题,我用的是transformers 3.0.2

@FLxuRu FLxuRu closed this as completed Dec 23, 2020
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