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

Feature/pytorch lightning integration -> research/ablation-study #1

Merged

Conversation

MaloOLIVIER
Copy link
Owner

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:

Data Handling Refactor:

- 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
… | 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.
@MaloOLIVIER MaloOLIVIER merged commit c1bf0a7 into research/ablation_study Dec 6, 2024
0 of 2 checks passed
@MaloOLIVIER MaloOLIVIER deleted the feature/pytorch-lightning-integration branch December 6, 2024 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant