Description
During evaluation (evaluate_finetune.py), inference_loop crashes with a RuntimeError when sequences in the dataset have different lengths:
RuntimeError: Sizes of tensors must match except in dimension 0. Expected size 512 but got size 440
Suggestion fix:
def pad_patient(patient, max_length): # for me for instance max_length=512
pad_fields = {
"concepts": 0,
"segments": 0,
"ages": 0.0,
"abspos": 0.0,
}
for field, pad_value in pad_fields.items():
values = getattr(patient, field)
if len(values) < max_length:
padded = values + [pad_value] * (max_length - len(values))
else:
padded = values[:max_length]
setattr(patient, field, padded)
return patient
test_data.patients = [pad_patient(p) for p in test_data.patients]
Description
During evaluation (
evaluate_finetune.py),inference_loopcrashes with aRuntimeErrorwhen sequences in the dataset have different lengths:RuntimeError: Sizes of tensors must match except in dimension 0. Expected size 512 but got size 440
Suggestion fix:
test_data.patients = [pad_patient(p) for p in test_data.patients]