[pycaffe] expose Net::CopyTrainedLayersFrom as Net.copy_from
authorJonathan L Long <jonlong@cs.berkeley.edu>
Wed, 1 Oct 2014 02:06:18 +0000 (19:06 -0700)
committerJonathan L Long <jonlong@cs.berkeley.edu>
Thu, 2 Oct 2014 19:47:59 +0000 (12:47 -0700)
This allows finetuning from Python, for example.

python/caffe/_caffe.cpp
python/caffe/_caffe.hpp

index 5a81a42..5696f26 100644 (file)
@@ -147,6 +147,7 @@ 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("_forward",              &PyNet::Forward)
       .def("_backward",             &PyNet::Backward)
       .def("reshape",               &PyNet::Reshape)
index 622e887..a15144b 100644 (file)
@@ -96,6 +96,9 @@ 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 Forward(int start, int end) { net_->ForwardFromTo(start, end); }
   void Backward(int start, int end) { net_->BackwardFromTo(start, end); }
   void Reshape() { net_->Reshape(); }