bert_document_classification icon indicating copy to clipboard operation
bert_document_classification copied to clipboard

forward() got an unexpected keyword argument 'device'

Open basti97 opened this issue 4 years ago • 1 comments

Hello,

thanks for sharing your code. I am new to BERT and finetuning and I tried your code with costumn data.

I recieved following error on running DocumentBertMaxPool/DocumentBertLinear:

_` batch_predictions = self.bert_doc_classification(batch_document_tensors, 185 batch_document_sequence_lengths, --> 186 freeze_bert=self.args['freeze_bert'], device=self.args['device']) 187 188 batch_correct_output = correct_output[i:i + self.args['batch_size']].to(device=self.args['device'])

/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py in call(self, *input, **kwargs) 530 result = self._slow_forward(*input, **kwargs) 531 else: --> 532 result = self.forward(*input, **kwargs) 533 for hook in self._forward_hooks.values(): 534 hook_result = hook(self, input, result)

TypeError: forward() got an unexpected keyword argument 'device'_ `

I think the reason for this problem is that there is missing the 'freeze_bert'-argument in the forward-method of the model architecture (document_bert_architectures.py).

Thanks for response.

basti97 avatar Jun 11 '21 08:06 basti97

I am getting a similar error with the forward function, did you manage to figure out what was the issue?

zeinramadan avatar Aug 04 '21 11:08 zeinramadan