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

Need the ability to resume training from a saved checkpoint #61

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions configs/vae.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ logging_params:
save_dir: "logs/"
name: "VanillaVAE"

custom_params:
resume_training: false
resume_chkpt_path: ""
10 changes: 10 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import argparse
import numpy as np
from pathlib import Path
from collections import OrderedDict
from models import *
from experiment import VAEXperiment
import torch.backends.cudnn as cudnn
Expand Down Expand Up @@ -36,6 +37,15 @@
seed_everything(config['exp_params']['manual_seed'], True)

model = vae_models[config['model_params']['name']](**config['model_params'])
if 'custom_params' in config:
if config['custom_params']['resume_training']:
checkpoint = torch.load(config['custom_params']['resume_chkpt_path'])
state_dict = checkpoint['state_dict']
new_state_dict = OrderedDict()
for k, v in state_dict.items():
new_state_dict[k.replace("model.", "")] = v
model.load_state_dict(new_state_dict)

experiment = VAEXperiment(model,
config['exp_params'])

Expand Down