pycaffe: add shape accessor
authorJeff Donahue <jeff.donahue@gmail.com>
Thu, 6 Aug 2015 20:46:11 +0000 (13:46 -0700)
committerJeff Donahue <jeff.donahue@gmail.com>
Fri, 7 Aug 2015 20:54:41 +0000 (13:54 -0700)
python/caffe/_caffe.cpp

index dff7f62..bb5130f 100644 (file)
@@ -230,6 +230,11 @@ BOOST_PYTHON_MODULE(_caffe) {
 
   bp::class_<Blob<Dtype>, shared_ptr<Blob<Dtype> >, boost::noncopyable>(
     "Blob", bp::no_init)
+    .add_property("shape",
+        bp::make_function(
+            static_cast<const vector<int>& (Blob<Dtype>::*)() const>(
+                &Blob<Dtype>::shape),
+            bp::return_value_policy<bp::copy_const_reference>()))
     .add_property("num",      &Blob<Dtype>::num)
     .add_property("channels", &Blob<Dtype>::channels)
     .add_property("height",   &Blob<Dtype>::height)