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

i want to save best model with 'optimizer', 'param_schedulers' #3742

Open
Md-Sayeed-Khan opened this issue Jul 17, 2024 · 1 comment
Open

Comments

@Md-Sayeed-Khan
Copy link

No description provided.

@0xD4rky
Copy link

0xD4rky commented Aug 24, 2024

saving the best model along with the optimizer state and parameter schedulers typically involves configuring the training pipeline and checkpointing mechanisms.

suppose this is your sample training script which saves the best optimizer state and scheduler.

train_segmentor(config_file, 
                 checkpoint_config=dict(
                     interval=1,
                     out_dir='./checkpoints',
                     save_optimizer=True,
                     save_scheduler=True,
                     max_keep_ckpts=3
                 ),
                 evaluation=dict(
                     interval=1,
                     metric='mIoU',
                     save_best='mIoU'
                 ))

this is how you will save your checkpoint using different utilities of any openmmlab's toolkit.

from mmcv.runner import save_checkpoint
from mmseg.models import build_segmentor
from mmseg.datasets import build_dataset
from mmseg.apis import init_segmentor


checkpoint_path = 'path/to/your/manual_checkpoint.pth'
save_checkpoint(
    model,
    checkpoint_path,
    optimizer=model.optimizer,
    meta={'epoch': 10, 'iter': 1000}  # Example meta information
)

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

No branches or pull requests

2 participants