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

Why is snapshot not exposed through the Python interface? #3077

Closed
gustavla opened this issue Sep 17, 2015 · 5 comments
Closed

Why is snapshot not exposed through the Python interface? #3077

gustavla opened this issue Sep 17, 2015 · 5 comments

Comments

@gustavla
Copy link
Contributor

I have written a Python script to manage my training and I'm adding a signal interrupt handler that upon receiving SIGTERM will finish its current iteration and then snapshot and safely quit.

However, I noticed that Solver::Snapshot is protected and thus not exposed to Python. I don't understand why this is the case, since my use case seems perfectly reasonable. Changing this locally and adding snapshot to python/_caffe.cpp has worked out well for me so far.

A way around it might be to somehow change the snapshot parameter through Python and that way force a snapshot to be made at the next iteration. I don't even know if this is possible, but even it is it's quite an ugly hack compared to just calling snapshot(). It would also delay the snapshot by one iteration.

@seanbell
Copy link

See Fast R-CNN (https://github.com/rbgirshick/fast-rcnn/blob/master/lib/fast_rcnn/train.py#L48) as an example of performing a snapshot in Python. This example has extra re-scaling of weights, but essentially you just call net.save().

@gustavla
Copy link
Contributor Author

Calling save only produces a .caffemodel file with the weights. To correctly resume SGD with momentum, I also need the latest gradients in a .solverstate file.

@ronghanghu
Copy link
Member

Personally I think it is better to expose Snapshot function to pycaffe. I can write a PR for that when less busy.

@gustavla
Copy link
Contributor Author

I agree. I can also arrange a PR, since I have already made these changes locally.

gustavla added a commit to gustavla/caffe that referenced this issue Sep 18, 2015
- Solver::Snapshot is made public
- It is also added as `snapshot` to pycaffe

Addressing BVLC#3077
@longjon
Copy link
Contributor

longjon commented Nov 5, 2015

Closing as addressed by #3082.

@longjon longjon closed this as completed Nov 5, 2015
mtamburrano pushed a commit to mtamburrano/caffe that referenced this issue Nov 12, 2015
- Solver::Snapshot is made public
- It is also added as `snapshot` to pycaffe

Addressing BVLC#3077
acmiyaguchi pushed a commit to acmiyaguchi/caffe that referenced this issue Nov 13, 2017
- Solver::Snapshot is made public
- It is also added as `snapshot` to pycaffe

Addressing BVLC#3077
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

4 participants