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

Error when coverting from bert pytorch_pretrained_bert to bert from transformers library TypeError: forward() got an unexpected keyword argument 'output_all_encoded_layers' #11

Open
RihabElya opened this issue Apr 1, 2021 · 0 comments

Comments

@RihabElya
Copy link

def forward(self, batch):
"""
batch has the following structure:
data[0]: list, tokens ids
data[1]: list, tokens mask
data[2]: list, tokens type ids (for bert)
data[3]: list, bert labels ids
"""
encoded_layers, _ = self.model(
input_ids=batch[0],
token_type_ids=batch[2],
attention_mask=batch[1],
output_all_encoded_layers=self.config["mode"] == "weighted")
if self.config["mode"] == "weighted":
encoded_layers = torch.stack([a * b for a, b in zip(encoded_layers, self.bert_weights)])
return self.bert_gamma * torch.sum(encoded_layers, dim=0)
return encoded_layers

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

1 participant