Finetuning ELMO: code crashes when list is empty
Closed this issue · 1 comments
caspillaga commented
Line 675 of elmoft.py crashes when the list is empty
def eval(...):
...
elif task_type == 'nmt':
tkns_tnsr, lb_tnsr = zip(*[(sx.split(SC), list(map(int, sy.split(SC)))) for sx, sy in zip(tkns_tnsr, lb_tnsr) if ((type(sx) is str and sx != '') or len(sx) > 0) and ((type(sy) is str and sy != '') or len(sy) > 0)])
If the list is empty, i.e. tkns_tnsr, lb_tnsr = zip(*[])
, The code crashes
A sanity check (like the one in line 676) should be added before line 675
cskyan commented
Line 675 of elmoft.py crashes when the list is empty
def eval(...): ... elif task_type == 'nmt': tkns_tnsr, lb_tnsr = zip(*[(sx.split(SC), list(map(int, sy.split(SC)))) for sx, sy in zip(tkns_tnsr, lb_tnsr) if ((type(sx) is str and sx != '') or len(sx) > 0) and ((type(sy) is str and sy != '') or len(sy) > 0)])
If the list is empty, i.e.
tkns_tnsr, lb_tnsr = zip(*[])
, The code crashesA sanity check (like the one in line 676) should be added before line 675
This bug is fixed. I am just wondering in what situation the list would be empty. The model assumes that the inputted text and labels are pre-processed. Either empty text or labels should be filtered. If you are using your own dataset please consider adding a pre-process step before putting the data into the model.