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

Train using predefined weights in Python #1566

Closed
LordSputnik opened this issue Dec 12, 2014 · 1 comment
Closed

Train using predefined weights in Python #1566

LordSputnik opened this issue Dec 12, 2014 · 1 comment

Comments

@LordSputnik
Copy link

Is there a particular reason why it isn't possible at the moment to use the Solver in Python to start from a pretrained network? As far as I can tell (and I don't have much experience with caffe, so I may be completely wrong), it would just be a case of creating a new constructor:

PySGDSolver::PySGDSolver(const string& param_file, const string& pretrained_param_file) {
    // as in PyNet, (as a convenience, not a guarantee), create a Python
    // exception if param_file can't be opened
    CheckFile(param_file);
    solver_.reset(new SGDSolver<float>(param_file));
    // we need to explicitly store the net wrapper, rather than constructing
    // it on the fly, so that it can hold references to Python objects
    net_.reset(new PyNet(solver_->net()));

    solver_->net()->CopyTrainedLayersFrom(pretrained_param_file);
}
@shelhamer
Copy link
Member

You can fine-tune from Python:

solver = caffe.SGDSolver('solver.prototxt')
solver.net.copy_from('pretrained_param_file')
[...]

See #1703 for the next version of the Python interface, where you could suggest the convenience constructor for fine-tuning.

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