Skip to content

Add a util function for training loop#34

Merged
SarahAlidoost merged 8 commits intomainfrom
fix_33
Apr 8, 2026
Merged

Add a util function for training loop#34
SarahAlidoost merged 8 commits intomainfrom
fix_33

Conversation

@SarahAlidoost
Copy link
Copy Markdown
Member

@SarahAlidoost SarahAlidoost commented Mar 18, 2026

closes #33

relates #13 using torch.utils.tensorboard

@SarahAlidoost SarahAlidoost changed the title Fix 33 Add a util function for training loop Mar 18, 2026
@SarahAlidoost
Copy link
Copy Markdown
Member Author

SarahAlidoost commented Mar 18, 2026

@rogerkuou I am implementing the training loop as a util function in this PR, also saving model and its config. I have to change the example notebook, but lets see how much we can change in other PR #27 and merge that one first.

@SarahAlidoost SarahAlidoost marked this pull request as ready for review April 1, 2026 15:52
@SarahAlidoost SarahAlidoost requested a review from rogerkuou April 1, 2026 15:52
@SarahAlidoost SarahAlidoost mentioned this pull request Apr 3, 2026
Copy link
Copy Markdown
Collaborator

@rogerkuou rogerkuou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @SarahAlidoost, thanks for making this util function! I managed to run the example notebook on my local.

I just have one minor comment on saving the best model to the log dir. Please feel free to adapt it or not.

After merging I will start to use this util function in PR #27


def _save_model(model: torch.nn.Module, log_dir: str, verbose: bool) -> None:
"""Save model state and config to disk."""
model_path = Path(log_dir) / "best_model.pth"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am wondering if it is a common pratice to output the best model to the log dir? If yes let's keep it!

Copy link
Copy Markdown
Member Author

@SarahAlidoost SarahAlidoost Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typically they store everything in one run directory. So, it is better to rename log_dir to run_dir.

@SarahAlidoost
Copy link
Copy Markdown
Member Author

SarahAlidoost commented Apr 8, 2026

Hi @SarahAlidoost, thanks for making this util function! I managed to run the example notebook on my local.

I just have one minor comment on saving the best model to the log dir. Please feel free to adapt it or not.

After merging I will start to use this util function in PR #27

thanks for reviewing. While I was working on #32, I found that it is better to have a train.py instead of utils. I move the function to new script and update import in the nb before merging this.

@SarahAlidoost SarahAlidoost merged commit 65f75f9 into main Apr 8, 2026
3 checks passed
@SarahAlidoost SarahAlidoost deleted the fix_33 branch April 8, 2026 11:32
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.

Add a util function for training loop

2 participants