DDRNet.pytorch icon indicating copy to clipboard operation
DDRNet.pytorch copied to clipboard

UnboundLocalError on resume

Open visualDust opened this issue 1 year ago • 3 comments

UnboundLocalErrors occur on resume training. valid_loss and mean_IoU are obtained by code below:

in train.py:

if epoch % 10:
    valid_loss, mean_IoU, IoU_array = validate(config, testloader, model, writer_dict)

That means valid_loss and mean_IoU are calculated on each 10 steps. However, they are printed on each step. Therefore, if you make RESUME: true in configs, and your previous model was NOT on epochs that are multiples of 10, errors will occur:

UnboundLocalError: local variable 'valid_loss' referenced before assignment.
UnboundLocalError: local variable 'mean_IoU' referenced before assignment.

visualDust avatar Nov 18 '23 07:11 visualDust