Implement Grad-CAM explainability and tests - #3
Conversation
…dles for proper cleanup.
|
Implemented 1D Grad-CAM with successful CI tests. Ready for merge. |
There was a problem hiding this comment.
Pull request overview
This PR implements 1D Grad-CAM (Gradient-weighted Class Activation Mapping) explainability for spectral CNN models, providing visual interpretability of model predictions. The implementation includes comprehensive unit tests, documentation, and demonstration notebooks.
Key Changes:
- New
GradCAM1Dutility class for generating attention heatmaps on 1D spectral data - Comprehensive test suite with edge case coverage for the Grad-CAM implementation
- Resource management improvements with added
close()method to dataset and test cleanup
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| spectra2prop/utils/explainability.py | Implements the GradCAM1D class with automatic Conv1d layer detection, hook registration, and heatmap generation capabilities |
| tests/test_explainability.py | Comprehensive test suite covering initialization, layer detection, heatmap generation, normalization, and hook management |
| tests/test_dataloader.py | Adds proper resource cleanup by calling dataset.close() after tests complete |
| spectra2prop/data/dataloader.py | Adds close() method to MGFDataset for proper file handle cleanup |
| notebooks/showcase.ipynb | Demonstrates Grad-CAM usage with visualization examples for spectral data interpretation |
| .github/workflows/ci.yml | Updates PYTHONPATH from src to . for correct test execution |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@RaykKretzschmar I've opened a new pull request, #4, to work on those changes. Once the pull request is ready, I'll request review from you. |
…nd use logits for target score calculation.
Co-authored-by: RaykKretzschmar <112646288+RaykKretzschmar@users.noreply.github.com>
Add test coverage for automatic class selection in GradCAM heatmap generation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 6 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@RaykKretzschmar I've opened a new pull request, #5, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: RaykKretzschmar <112646288+RaykKretzschmar@users.noreply.github.com>
|
@RaykKretzschmar I've opened a new pull request, #6, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: RaykKretzschmar <112646288+RaykKretzschmar@users.noreply.github.com>
Add tearDown hook cleanup to prevent memory leaks in GradCAM tests
|
@RaykKretzschmar I've opened a new pull request, #7, to work on those changes. Once the pull request is ready, I'll request review from you. |
Co-authored-by: RaykKretzschmar <112646288+RaykKretzschmar@users.noreply.github.com>
Co-authored-by: RaykKretzschmar <112646288+RaykKretzschmar@users.noreply.github.com>
Align DummySpectralCNN test model with real SpectralCNN tuple return signature
No description provided.