ebagdasa/backdoors101

Bug in save_model function

phil0042 opened this issue · 1 comments

Hi,
the save_model function does not properly save the best checkpoint. The reason being the following two lines of code.

self.best_loss = float('inf')

if val_loss < self.best_loss:

During training, save_model is called and loss_val contains the accuracy of the current iteration on the test set, not the loss value.

Fix:
Change the initial value of self.best_loss and modify the comparison (maybe rename self.best_loss and val_loss as well).
self.best_loss = float(0) and if val_loss >= self.best_loss:

yeah, makes sense, please feel free to do a PR! Thanks for noticing it!