-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Total Variance Minimization with PyTorch support #2673
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
Conversation
…t cases assessing memory usage, input size, channel dimension (first/last), clip values range, convergence, reproducibility and consistency across runs with same seed. L1 norm has a good convergence with torch LBFGS, L2 hyperparameters must be selected carefully Signed-off-by: Matteo Fasulo <[email protected]>
Hi @MatteoFasulo Thank you for your pull request, I'll add a review in the next few days. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev_1.21.0 #2673 +/- ##
===========================================
Coverage 85.17% 85.18%
===========================================
Files 329 330 +1
Lines 29731 29820 +89
Branches 4991 5007 +16
===========================================
+ Hits 25324 25402 +78
- Misses 2976 2983 +7
- Partials 1431 1435 +4
🚀 New features to boost your workflow:
|
@MatteoFasulo Could you please fix the style checks and CodeQL alerts above? Run Black formatter (version |
Sure, I will do that in the next few days. |
… variable in test variance minimization pytorch Signed-off-by: Matteo Fasulo <[email protected]>
Signed-off-by: Matteo Fasulo <[email protected]>
Signed-off-by: Matteo Fasulo <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @MatteoFasulo Thank you very much for your pull request. I have added 3 minor change requests, could you please push the changes?
tests/defences/preprocessor/test_variance_minimization_pytorch.py
Outdated
Show resolved
Hide resolved
…mentation on its usage. Signed-off-by: Matteo Fasulo <[email protected]>
Sure, I added the three suggested changes in the last commit. I removed the unused numpy import, added the |
if TYPE_CHECKING: | ||
from art.utils import CLIP_VALUES_TYPE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if TYPE_CHECKING: | |
from art.utils import CLIP_VALUES_TYPE | |
if TYPE_CHECKING: | |
import torch | |
from art.utils import CLIP_VALUES_TYPE |
Hi @MatteoFasulo Thank you! I have missed this before, an additional import of torch is necessary for the typing to pass the Style Checks. Please add the code suggestion above and run Black formatter again to ensure correct line formatting. Afterwards we should be good to merge. |
Signed-off-by: MatteoFasulo <[email protected]>
Hi @beat-buesser, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @MatteoFasulo Thank you very much for your contribution to ART!
Description
Implemented Total Variation Minimization using PyTorch with GPU support, closely modeled after the existing CPU-based scipy.optimize.minimize approach. The CPU version iteratively minimizes over each image in the batch and each channel individually, resulting in time complexity of O(B × C) where B is the batch size and C the number of channels. Additionally, loss computation on the CPU introduces extra latency per iteration. The new PyTorch-based implementation enables parallelized, accelerated computation directly on the GPU, significantly improving runtime performance.
Type of change
Please check all relevant options.
Testing
Extensive test coverage was added via
pytest tests/defences/preprocessor/test_variance_minimization_pytorch.py --framework="pytorch"
validating:
Test Configuration:
Checklist