valeoai / ConfidNet

Addressing Failure Prediction by Learning Model Confidence

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Attempts to pre-train models results in error: UnboundLocalError: local variable 'pred' referenced before assignment

matt-deboer opened this issue · comments

Issuing the recommended training command python3 train.py -c confs/exp_cifar10.yaml (or the same with cifar100) results in the following error:

Traceback (most recent call last):
  File "train.py", line 135, in <module>
    main()
  File "train.py", line 131, in main
    learner.train(epoch)
  File "/ConfidNet/confidnet/learners/default_learner.py", line 80, in train
    val_losses, scores_val = self.evaluate(self.val_loader, self.prod_val_len, split="val")
  File "/ConfidNet/confidnet/learners/default_learner.py", line 179, in evaluate
    metrics.update(pred, target, confidence)
UnboundLocalError: local variable 'pred' referenced before assignment

In debug, I noticed that the value of mode passed into evaluate(...) is taking the default of "normal", which of course is not handled in any of the if-clauses. Any idea what is expected to happen in "normal" mode?

Should the default value for mode instead be "mcp"? (I am able to proceed with training if I make this modification, but I'm not sure that this is achieving the intended result)

Hi @matt-deboer,

The default value for mode should indeed be mcp. When updating the repo, I may have forget to update in the evaluate() function.

Anyway, thanks for pointing out, I've corrected this issue in commit 9ef5e6c
Please let me know it that fixed your problem.

Charles

Fixed! Thanks much.