-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/pytorch lightning integration -> research/ablation-study #1
Merged
MaloOLIVIER
merged 32 commits into
research/ablation_study
from
feature/pytorch-lightning-integration
Dec 6, 2024
Merged
Feature/pytorch lightning integration -> research/ablation-study #1
MaloOLIVIER
merged 32 commits into
research/ablation_study
from
feature/pytorch-lightning-integration
Dec 6, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Refactored to use LightningModule - Updated training and validation steps with Lightning's hooks - Added PyTorch Lightning configurations - need to further integrate Lightning and Hydra by leveraging Julien' HAURET's VibraVox
- Add HungarianDataModule using LightningDataModule - Update HNetGRULightning to use torchmetrics for F1Score - Implement TensorBoard logging for loss and F1-score - Modify train_hnet.py to utilize the new DataModule and model classes
- **Enhanced Docstrings:** - Added comprehensive documentation to the class and its methods, detailing attributes and functionalities. - **Refactored F1 Metrics:** - Consolidated , , and into a single metric instance with set dynamically based on . - **Added Type Annotations:** - Included type hints for methods such as , , , and to improve code clarity and type checking. - **Updated ModelCheckpoint Monitoring:** - Changed the parameter from to to align with updated logging keys. - **Enhanced Logging Mechanism:** - Implemented a method to centralize the logging of loss and F1-score across training, validation, and test phases. - **Minor Imports Adjustment:** - Updated import statements to include from for type annotations.
- Update test_step method signature formatting in models.py for better readability - Simplify on_test_start by removing unnecessary test_config logging - Add trainer.test call in train_hnet.py to execute testing after training
…xt | removed docs from run.py
… | the Metric Collection is instanciated by Hydra and loads the F1Score | consequently a dictionary of metrics is logged
…up configurations - **Use Hydra to instantiate DataModule and LightningModule:** - Replaced manual instantiation with HungarianDataModule and HNetGRULightning. - **Remove hard-coded dataset paths:** - Eliminated hard-coded filename_train and filename_test to rely on Hydra configurations. - **Update imports:** - Removed unused imports such as datetime, random, sys, and warnings. - Added necessary imports like DictConfig from omegaconf, hydra from hydra.core, and Trainer from lightning.pytorch. - **Clean up Trainer instantiation:** - Removed the os.makedirs and related directory creation logic. - Updated Trainer instantiation to exclude gpus argument and ensure proper callback management. - **Enhance documentation:** - Improved docstrings for better clarity and understanding of the main function's purpose. - **Miscellaneous:** - Added type hints for better code readability and maintenance. **Benefits:** - Enhances configurability and flexibility by leveraging Hydra's powerful configuration management. - Simplifies the run.py script by removing hard-coded values and unused components. - Improves code maintainability and readability through better documentation and type hinting.
…ttentionLayer - Rename fixture model to hnetgru in conftest.py for clarity - Update tests_consistency_hnet_gru.py to use the renamed hnetgru fixture - Add test_AttentionLayer_init to tests_consistency_attention_layer.py - Remove tests from tests_scenarios_attention_layer.py - isort + black
…ting** - **.gitignore:** - Changed .coverage to .coverage* to ignore all coverage-related files. - **Configuration (configs/run.yaml):** - Increased nb_epochs from 2 to 30 for more comprehensive testing. - Set sample_range_used as a hyphen-separated string 3000-5000-15000. - **Lightning Module (hnet_gru_lightning.py):** - Added a default device parameter that automatically selects CUDA if available, otherwise CPU. - **Pytest Configuration (pytest.ini):** - Added a new marker scenarios_generate_data for tests that generate data during scenario-based testing. - **Run Script (run.py):** - Removed the device argument from hydra.utils.instantiate to handle device selection within the Lightning module itself. - **Conftest (tests/scenarios_tests/conftest.py):** - Removed the cfg fixture and custom Hydra override options to streamline configuration handling. - **Test Scripts:** - **General Improvements:** - Utilized pathlib.Path for more robust path manipulations. - **Specific Changes in test_scenarios_run.py:** - Modified sample_range_used to be a hyphen-separated string. - Removed unused imports and cleaned up fixtures. - Ensured all tests assert successful completion with clear messages. **Summary:** These changes enhance the testing framework by improving configuration flexibility, ensuring better handling of coverage files, and refining test scripts for reliability and readability. The updates facilitate more extensive and accurate testing scenarios, contributing to the robustness of the HNetGRU model development.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request includes several changes aimed at improving the configuration and data handling for the Hungarian Network project. The most significant updates involve adding new configuration files for various components and refactoring the dataset class.
Configuration Updates:
.github/workflows/ci-cd.yml
: Removed a TODO comment regarding upgrading the project to the latest Python version.configs/callbacks/hnet_checkpoint.yaml
: Added a new configuration for theModelCheckpoint
callback to save the last model and the top-performing model based on validation loss.configs/callbacks/rich_model_summary.yaml
: Introduced a new configuration for theRichModelSummary
callback with a maximum depth of 3.configs/logging/tensorboard.yaml
: Added a new configuration for logging usingTensorBoardLogger
with specified logging steps and directory.configs/metrics/f1.yaml
: Added a new configuration for theF1Score
metric, specifying it as a multiclass task with weighted averaging.configs/run.yaml
: Created a top-level configuration file forrun.py
, defining various parameters and composing other configuration files.configs/trainer/ddp.yaml
: Added a new configuration for theTrainer
with distributed data parallel (DDP) strategy and GPU acceleration.Data Handling Refactor:
hungarian_net/dataset.py
: Removed the oldHungarianDataset
class.hungarian_net/lightning_datamodules/hungarian_datamodule.py
: Added a newHungarianDataset
class with improved documentation and methods for handling class imbalance and weighted accuracy. Introduced aHungarianDataModule
class to encapsulate data loading logic for training, validation, and testing.