Traceback (most recent call last): File "run_bert.py", line 222, in <module> main() File "run_bert.py", line 215, in main run_train(args) File "run_bert.py", line 120, in run_train trainer.train(train_data=train_dataloader, valid_data=valid_dataloader) File "C:\MyDrive\PythonWs\NextGenWs\harshitha\Bert\IonePatient-our model\pybert\train\trainer.py", line 153, in train train_log = self.train_epoch(train_data) File "C:\MyDrive\PythonWs\NextGenWs\harshitha\Bert\IonePatient-our model\pybert\train\trainer.py", line 132, in train_epoch metric(logits=self.outputs, target=self.targets) File "C:\MyDrive\PythonWs\NextGenWs\harshitha\Bert\IonePatient-our model\pybert\train\metrics.py", line 47, in __call__ correct = pred.eq(target.view(1, -1).expand_as(pred)) RuntimeError: The expanded size of the tensor (9068) must match the existing size (453400) at non-singleton dimension 1. Target sizes: [5, 9068]. Tensor sizes: [1, 453400]
I tried this with my data and it trained fine. But when I tried to get the Accuracy Metric while training, it threw this error.
I passed accuracy metric like this Accuracy(topK=5) in the trainer object in the run_bert.py file.
Any idea what is the fix for this?