Open davor10105 opened 4 months ago
Any thoughts on this? @annahedstroem @annariasdu
Hi @davor10105 ! Sorry for the delayed response and thanks for your correct observation about our preliminary efforts towards batching and for offering to help!
The performance gains look really impressive. I would love to review your changes in a PR, where it also should become much clearer what the test scope would be.
Looking forward!
Also, I created a discord channel for us: https://discord.gg/U8PsVSv8 we can continue the communication there!
Hi @davor10105,
some time ago we used to have 2 different base classes and maintaining those got out of hand, so we opted for a short term workaroung (just using a for loop to make the API look like batched one https://github.com/understandable-machine-intelligence-lab/Quantus/pull/294).
I guess it's true, that temporary workarounds are the most permanant parts of software 😭
Hey @annahedstroem , Thank you for creating such an excellent library. I've been using it extensively in my recent research, and it's been incredibly helpful.
While working with the library, I noticed that although most metric implementations support batch processing via the
evaluate_batch
method, they do not seem to be optimized for true batch processing. Instead, they iterate over each element in the batch, concatenating the final scores at the end.I would love to contribute to your library by implementing true batch processing for these metrics. This optimization would significantly reduce evaluation times. Would you be open to this contribution?
Below, you will find code snippets showcasing my batch implementation of the
evaluate_batch
methods for the PixelFlipping and MaxSensitivity metrics. Additionally, I have included helper functions required for calculating these specific metrics. This implementation is a preliminary proof of concept, and with your approval, I would like to properly integrate these changes into the library.Following the code snippets, I have included two plots that illustrate the performance gains achieved with these modified implementations. These results are based on 30 repetitions. As shown in the figures, the true batch version for PixelFlipping is 18 times faster than the current implementation, and for MaxSensitivity, the performance gain is 2.3 times.
Results for PixelFlipping:
Results for MaxSensitivity:
Please let me know your thoughts on this suggestion and if it would be alright for me to proceed with reimplementing the metrics.
Kind regards, Davor