1 #ifndef CAFFE_PYTHON_LAYER_HPP_     2 #define CAFFE_PYTHON_LAYER_HPP_     4 #include <boost/python.hpp>     7 #include "caffe/layer.hpp"     9 namespace bp = boost::python;
    13 template <
typename Dtype>
    16   PythonLayer(PyObject* 
self, 
const LayerParameter& param)
    17       : 
Layer<Dtype>(param), self_(bp::handle<>(bp::borrowed(
self))) { }
    23     if (this->
phase_ == TRAIN && Caffe::solver_count() > 1
    24         && !Caffe::multiprocess()) {
    25       LOG(FATAL) << 
"PythonLayer does not support CLI Multi-GPU, use train.py";
    27     self_.attr(
"param_str") = bp::str(
    29     self_.attr(
"phase") = 
static_cast<int>(this->
phase_);
    30     self_.attr(
"setup")(bottom, top);
    34     self_.attr(
"reshape")(bottom, top);
    37   virtual inline const char* 
type()
 const { 
return "Python"; }
    42     self_.attr(
"forward")(bottom, top);
    45       const vector<bool>& propagate_down, 
const vector<
Blob<Dtype>*>& bottom) {
    46     self_.attr(
"backward")(top, propagate_down, bottom);
 An interface for the units of computation which can be composed into a Net. 
Definition: layer.hpp:33
A layer factory that allows one to register layers. During runtime, registered layers can be called b...
Definition: blob.hpp:14
virtual void Backward_cpu(const vector< Blob< Dtype > *> &top, const vector< bool > &propagate_down, const vector< Blob< Dtype > *> &bottom)
Using the CPU device, compute the gradients for any parameters and for the bottom blobs if propagate_...
Definition: python_layer.hpp:44
virtual void LayerSetUp(const vector< Blob< Dtype > *> &bottom, const vector< Blob< Dtype > *> &top)
Does layer-specific setup: your layer should implement this function as well as Reshape. 
Definition: python_layer.hpp:19
Definition: python_layer.hpp:14
virtual void Forward_cpu(const vector< Blob< Dtype > *> &bottom, const vector< Blob< Dtype > *> &top)
Using the CPU device, compute the layer output. 
Definition: python_layer.hpp:40
Phase phase_
Definition: layer.hpp:299
LayerParameter layer_param_
Definition: layer.hpp:297
virtual const char * type() const
Returns the layer type. 
Definition: python_layer.hpp:37
virtual void Reshape(const vector< Blob< Dtype > *> &bottom, const vector< Blob< Dtype > *> &top)
Adjust the shapes of top blobs and internal buffers to accommodate the shapes of the bottom blobs...
Definition: python_layer.hpp:32
A wrapper around SyncedMemory holders serving as the basic computational unit through which Layers...
Definition: blob.hpp:24