Closed marcusau closed 3 years ago
input_ids,segment_ids,input_mask these three tensor missing the batch dimension. you need to expand them from torch.Size([128]) to torch.Size([1,128])
you can try
input_ids = input_ids.unsqueeze(0)
segment_ids = segment_ids.unsqueeze(0)
input_mask = input_mask.unsqueeze(0)
it works. thanks you :)
可否一問.. 如何做online training? 我的NER model己finetune ..但部份新data...己做了標註,, 希望放入原來己fine-tuned的model內training...
麻煩你
可否一問.. 如何做online training? 我的NER model己finetune ..但部份新data...己做了標註,, 希望放入原來己fine-tuned的model內training...
麻煩你
don't support online training. You need to train with a mixture of old and new data.
I have trained the model.... and was planning to use the output model to predict the NER:
here are my codes. I defined max seq length =128 when training the model.
My initial of loading configs, tokenizer and model are all ok, but
still encounter with the following errors:
need_birnn : True rnn_dim: 128 max_seq_length: 128
torch.Size([128]) torch.Size([128])
Traceback (most recent call last): File "/home/ubuntu/PeijiYang/predict.py", line 155, in
logits = model.predict(input_ids, segment_ids, input_mask)
File "/home/ubuntu/PeijiYang/models.py", line 53, in predict
emissions = self.tag_outputs(input_ids, token_type_ids, input_mask)
File "/home/ubuntu/PeijiYang/models.py", line 40, in tag_outputs
outputs = self.bert(input_ids, token_type_ids=token_type_ids, attention_mask=input_mask)
File "/home/ubuntu/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 541, in call
result = self.forward(*input, **kwargs)
File "/home/ubuntu/.local/lib/python3.6/site-packages/transformers/modeling_bert.py", line 725, in forward
input_shape, attention_mask.shape
ValueError: Wrong shape for input_ids (shape torch.Size([128])) or attention_mask (shape torch.Size([128]))