Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reset min_max normalization values at the start of validation epoch #2153

Closed

Conversation

abc-125
Copy link
Contributor

@abc-125 abc-125 commented Jun 25, 2024

📝 Description

Currently, min_max values for normalization are updated every validation epoch. This update keeps irrelevant values from previous epochs by comparing new and old ones:
self.max = torch.max(self.max, torch.max(predictions))

It seems like it does not affect most of the models, but with at least EfficientAD, the final anomaly maps after training are normalized the wrong way (see #2139 or this discussion).

This fix resets min_max values at the beginning of every validation epoch to ensure that only values from the recent one will be used for normalization.

🛠️ Fixes #2027, thank you @CarlosNacher for pointing this problem out! Partially fixes #2139.

✨ Changes

Select what type of change your PR is:

  • 🐞 Bug fix (non-breaking change which fixes an issue)
  • 🔨 Refactor (non-breaking change which refactors the code base)
  • 🚀 New feature (non-breaking change which adds functionality)
  • 💥 Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • 📚 Documentation update
  • 🔒 Security update

✅ Checklist

Before you submit your pull request, please make sure you have completed the following steps:

  • 📋 I have summarized my changes in the CHANGELOG and followed the guidelines for my type of change (skip for minor changes, documentation updates, and test enhancements).
  • 📚 I have made the necessary updates to the documentation (if applicable).
  • 🧪 I have written tests that support my changes and prove that my fix is effective or my feature works (if applicable).

For more information about code review checklists, see the Code Review Checklist.

@abc-125
Copy link
Contributor Author

abc-125 commented Jun 25, 2024

Sorry, this was already solved in this PR.

@abc-125 abc-125 closed this Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant