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

Recommended way to load the model after training? #67

Open
peacej opened this issue Aug 22, 2022 · 2 comments
Open

Recommended way to load the model after training? #67

peacej opened this issue Aug 22, 2022 · 2 comments

Comments

@peacej
Copy link

peacej commented Aug 22, 2022

For example I guess this is one way?

from experiment import VAEXperiment
config = yaml.safe_load(open('configs/vae.yaml'))
ckpt = torch.load('logs/VanillaVAE/version_1/checkpoints/last.ckpt')
experiment = VAEXperiment(model, config['exp_params'])
experiment.load_state_dict(ckpt['state_dict'])

Then one can access the model via experiment.model

It took me a while to figure this out. Maybe add such instructions to the README?

@tudorjnu
Copy link

Hello! What model did you pass to the experiment?

@tudorjnu
Copy link

Nevermind, it works with:

from experiment import VAEXperiment
import yaml
import torch 
from models import *

config = yaml.safe_load(open('./configs/bbvae.yaml'))
model = vae_models[config['model_params']['name']](**config['model_params'])
ckpt = torch.load('./logs/BetaVAE/version_0/checkpoints/last.ckpt')
experiment = VAEXperiment(model, config['exp_params'])
experiment.load_state_dict(ckpt['state_dict'])

where I used the BetaVAE model.

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