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

关于ASGCN-BERT中的aspect_double_idx #218

Open
wkk-nlp opened this issue Dec 13, 2022 · 3 comments
Open

关于ASGCN-BERT中的aspect_double_idx #218

wkk-nlp opened this issue Dec 13, 2022 · 3 comments

Comments

@wkk-nlp
Copy link

wkk-nlp commented Dec 13, 2022

如果我用BERT预训练做ASGCN,aspect_double_idx修改成aspect_double_idx = torch.cat([left_len.unsqueeze(1), (left_len+aspect_len-1).unsqueeze(1)], dim=1)是正确的嘛,我按照上述修改会报错。
File "/root/autodl-tmp/ABSA-PyTorch-master/models/asgcn_bert.py", line 75, in mask
mask = torch.tensor(mask, dtype=torch.float).unsqueeze(2).to(self.opt.device)
ValueError: expected sequence of length 85 at dim 1 (got 90)

@wkk-nlp
Copy link
Author

wkk-nlp commented Dec 13, 2022

text_bert_indices, aspect_bert_indices, left_bert_indices, adj = inputs
text_len = torch.sum(text_bert_indices != 0, dim=-1)
aspect_len = torch.sum(aspect_bert_indices != 0, dim=-1)
left_len = torch.sum(left_bert_indices != 0, dim=-1)

@GeneZC
Copy link
Collaborator

GeneZC commented Dec 13, 2022

bert tokenizer 和普通的tokenizer不太一样,可以print出来debug下

@itsceleste7
Copy link

如果我用BERT预训练做ASGCN,aspect_double_idx修改成aspect_double_idx = torch.cat([left_len.unsqueeze(1), (left_len+aspect_len-1).unsqueeze(1)], dim=1)是正确的嘛,我按照上述修改会报错。 File "/root/autodl-tmp/ABSA-PyTorch-master/models/asgcn_bert.py", line 75, in mask mask = torch.tensor(mask, dtype=torch.float).unsqueeze(2).to(self.opt.device) ValueError: expected sequence of length 85 at dim 1 (got 90)

请问你有试过做ASGCN-BERT嘛?模型的输入应该怎么改呢?

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

3 participants