Skip to content

Commit

Permalink
Merge pull request BVLC#1195 from longjon/python-copy-from
Browse files Browse the repository at this point in the history
Expose Net.copy_from and Net.share_with in pycaffe
  • Loading branch information
shelhamer committed Oct 10, 2014
2 parents ec89ca2 + 5747075 commit cf9dd50
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions python/caffe/_caffe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ BOOST_PYTHON_MODULE(_caffe) {
bp::class_<PyNet, shared_ptr<PyNet> >(
"Net", bp::init<string, string>())
.def(bp::init<string>())
.def("copy_from", &PyNet::CopyTrainedLayersFrom)
.def("share_with", &PyNet::ShareTrainedLayersWith)
.def("_forward", &PyNet::Forward)
.def("_backward", &PyNet::Backward)
.def("reshape", &PyNet::Reshape)
Expand Down
6 changes: 6 additions & 0 deletions python/caffe/_caffe.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ class PyNet {
inline void check_contiguous_array(PyArrayObject* arr, string name,
int channels, int height, int width);

void CopyTrainedLayersFrom(const string filename) {
net_->CopyTrainedLayersFrom(filename);
}
void ShareTrainedLayersWith(PyNet* other) {
net_->ShareTrainedLayersWith(other->net_.get());
}
void Forward(int start, int end) { net_->ForwardFromTo(start, end); }
void Backward(int start, int end) { net_->BackwardFromTo(start, end); }
void Reshape() { net_->Reshape(); }
Expand Down

0 comments on commit cf9dd50

Please sign in to comment.