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

Saving model after finetuning #33

Open
sahilwalke17 opened this issue Aug 8, 2020 · 4 comments
Open

Saving model after finetuning #33

sahilwalke17 opened this issue Aug 8, 2020 · 4 comments

Comments

@sahilwalke17
Copy link

How do I save the model after fine-tuning using command line on dataset(CIFAR100) ?

@sickerin
Copy link

sickerin commented Aug 31, 2020

you gotta edit a line in train.py. In the PyTorch scripts, apparently the block that calls torch.save only gets executed when you enable the eval_every flag.

you can add this line torch.save at the end of the training so that it saves one final time before it finishes training

    # Final eval at end of training. and save model?
    run_eval(model, valid_loader, device, chrono, logger, step='end')
    torch.save({
                "step": step,
                "model": model.state_dict(),
                "optim" : optim.state_dict(),
            }, savename)

@charliewang789
Copy link

thx. this saved as a tar file, which contains a set of files. should it be a simple pt file?

@tianrengao
Copy link

I did as skcerin said. But failed to load to train, it says "expected cpu but got cuda:0"

@kyuhong0206
Copy link

you gotta edit a line in train.py. In the PyTorch scripts, apparently the block that calls torch.save only gets executed when you enable the eval_every flag.

you can add this line torch.save at the end of the training so that it saves one final time before it finishes training

    # Final eval at end of training. and save model?
    run_eval(model, valid_loader, device, chrono, logger, step='end')
    torch.save({
                "step": step,
                "model": model.state_dict(),
                "optim" : optim.state_dict(),
            }, savename)

how can use it? for test

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

5 participants