Develop#2
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds core training utilities (trainer loop, early stopping, checkpointing, logging) and introduces several tests/ smoke-test scripts intended to exercise these components, plus a config update for dataloader settings.
Changes:
- Added
Trainer,EarlyStopping, andCheckpointManagerimplementations undersrc/training/. - Added a reusable logger helper in
src/utils/logger.py. - Added multiple
tests/test_*.pyscripts and introduced a newdataloadersection inconfigs/default.yaml.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/test_trainer.py | Smoke script to run a minimal training loop using the new trainer/checkpoint/early-stopping/logger utilities. |
| tests/test_split_generator.py | Script intended to exercise dataset split generation (currently imports a missing module). |
| tests/test_sampler.py | Script intended to exercise balanced sampling (currently imports missing modules). |
| tests/test_logger.py | Script to validate logger output paths/handlers. |
| tests/test_early_stopping.py | Script to demonstrate early-stopping behavior over a synthetic loss curve. |
| tests/test_dataloader.py | Script intended to validate dataloader creation from config (currently imports a missing module). |
| tests/test_checkpoint.py | Script to validate checkpoint artifact writing (models/metrics/config). |
| src/utils/logger.py | Adds create_logger() helper that logs to file + console. |
| src/training/trainer.py | Adds a generic training loop with validation, checkpointing, and early stopping. |
| src/training/early_stopping.py | Adds an early-stopping utility based on validation loss improvements. |
| src/training/checkpoint.py | Adds a checkpoint manager for run directories, model weights, metrics, and config persistence. |
| configs/default.yaml | Adds a top-level dataloader config block (duplicates existing dataset batch/worker settings). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,12 @@ | |||
| from src.datasets.split_generator import DatasetSplitGenerator | |||
Comment on lines
+1
to
+2
| from src.datasets.sequence_dataset import SequenceDataset | ||
| from src.datasets.balanced_sampler import create_balanced_sampler |
| @@ -0,0 +1,26 @@ | |||
| from src.utils.config import load_config | |||
| from src.datasets.dataloader import create_dataloaders | |||
Comment on lines
+7
to
+9
| from pathlib import Path | ||
|
|
||
| import torch |
Comment on lines
+60
to
+66
| images = batch["sequence"].to(self.device) | ||
|
|
||
| labels = batch["label"].to(self.device) | ||
|
|
||
| self.optimizer.zero_grad() | ||
|
|
||
| outputs = self.model(images) |
Comment on lines
+118
to
+122
| epoch_loss = running_loss / len(self.val_loader) | ||
|
|
||
| epoch_acc = 100 * correct / total | ||
|
|
||
| return epoch_loss, epoch_acc |
Comment on lines
+28
to
+31
| logger.setLevel(logging.INFO) | ||
|
|
||
| logger.handlers.clear() | ||
|
|
|
|
||
| def __init__(self, root_dir="outputs/runs"): | ||
|
|
||
| timestamp = datetime.now().strftime("%Y%m%d_%H%M%S") |
| "w", | ||
| ) as f: | ||
|
|
||
| yaml.dump(config, f) |
Comment on lines
+36
to
+40
| dataloader: | ||
| batch_size: 8 | ||
| num_workers: 4 | ||
| pin_memory: true | ||
| drop_last: false |
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.