feat: complete Sprint 5 training infrastructure#3
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a new “main” training entrypoint and expands the training infrastructure with factories (model/optimizer/scheduler), richer checkpointing (including resume-related state), and a new ViT-based temporal model, along with updates to the default config and a set of smoke-test scripts.
Changes:
- Add
train.pyas the primary training script, wiring together config, model creation, optimization, scheduling, checkpointing, and early stopping. - Introduce factories for model/optimizer/scheduler selection via config and add a ViT + temporal pooling model implementation.
- Extend checkpoint saving to include optimizer/scheduler state and config/metrics artifacts; update default YAML to match new config keys.
Reviewed changes
Copilot reviewed 14 out of 15 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| train.py | New main training entrypoint that orchestrates the full training pipeline. |
| tests/test_training_pipeline.py | New end-to-end smoke script for a single forward/backward step. |
| tests/test_optimizer_scheduler.py | New smoke script to verify optimizer/scheduler factory creation. |
| tests/test_model_factory.py | New smoke script to verify model factory instantiation. |
| src/training/trainer.py | Adds tqdm progress bars, non-blocking transfers, scheduler stepping logic, and richer checkpoint saves. |
| src/training/scheduler_factory.py | New scheduler factory driven by config. |
| src/training/optimizer_factory.py | New optimizer factory driven by config. |
| src/training/checkpoint.py | Expands checkpoints to include optimizer/scheduler/epoch/best_loss and adds config/log/file artifact helpers. |
| src/models/vit_temporal_pooling.py | Adds a ViT backbone model with temporal pooling over frame features. |
| src/models/model_factory.py | New model factory keyed off config["model"]["name"]. |
| src/models/efficientnet_bilstm.py | Placeholder EfficientNet+BiLSTM model stub. |
| src/models/base_model.py | Adds a base model interface with a name property. |
| src/models/init.py | Exposes ModelFactory at the package level. |
| configs/default.yaml | Updates config schema (dataloader/model keys) to match new training infrastructure. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+17
to
+20
| from src.utils.config import load_config | ||
| from src.utils.logger import create_logger | ||
|
|
||
| from src.datasets.dataloader import create_dataloaders |
Comment on lines
+243
to
+247
| epoch, best_loss = checkpoint_manager.load_checkpoint( | ||
| checkpoint_path=args.resume, | ||
| model=model, | ||
| optimizer=optimizer, | ||
| scheduler=scheduler, |
Comment on lines
97
to
100
| epoch_loss = running_loss / len(self.train_loader) | ||
|
|
||
| epoch_acc = 100 * correct / total | ||
| epoch_acc = 100.0 * correct / total | ||
|
|
Comment on lines
149
to
152
| epoch_loss = running_loss / len(self.val_loader) | ||
|
|
||
| epoch_acc = 100 * correct / total | ||
| epoch_acc = 100.0 * correct / total | ||
|
|
Comment on lines
+173
to
+177
| if self.scheduler is not None: | ||
|
|
||
| if self.scheduler.__class__.__name__ == "ReduceLROnPlateau": | ||
|
|
||
| self.scheduler.step() | ||
| self.scheduler.step(val_loss) |
| patience=3, | ||
| ) | ||
|
|
||
| return None No newline at end of file |
Comment on lines
+31
to
+33
| elif model_name == "efficientnet_bilstm": | ||
|
|
||
| return EfficientNetBiLSTM() |
Comment on lines
+10
to
+12
| from src.utils.config import load_config | ||
| from src.datasets.dataloader import create_dataloaders | ||
| from src.models.model_factory import ModelFactory |
This file contains hidden or 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
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.
No description provided.