rewicks / ersatz

Apache License 2.0
39 stars 5 forks source link

RuntimeError: cannot reshape tensor #6

Open robotsp opened 2 years ago

robotsp commented 2 years ago

@rewicks @mjpost Dear contributor,

I came across an error when I train the model,

Traceback (most recent call last): File "trainer.py", line 419, in main() File "trainer.py", line 93, in main determiner=determiner) File "trainer.py", line 342, in run_epoch for i, (contexts, factors, labels, context_strings) in enumerate(self.training_set.batchify(batch_size)): File "/opt/yansongpeng/Mirli_Bert/Mirli_Bert/ersatz/dataset.py", line 214, in batchify context = context.view(len(data), -1) RuntimeError: cannot reshape tensor of 0 elements into shape [0, -1] because the unspecified dimension size -1 can be any value and is ambiguous

My training set is, ▁to ▁help ▁us ▁understand ▁what ▁has ▁been ▁happen ing . ||| ▁A t ▁the ▁start ▁of ▁the ▁crisis , ▁many ▁people |||

Would you please give me a hand? Thanks!

rewicks commented 2 years ago

Hi! It looks like the generated line doesn't have a label?

A generated line in the training data should look like:

, 00 0 ▁G old ? ||| ▁S A N ▁F ||| <eos>

Could you share the line from the original file that created this?

Also, as a temporary fix, you should be able to append <eos> to this line (assuming end of sentence is the intended label)

Are all of the lines in the training file missing the label?