From 3aa2fc0e3eaa75e254ed49eb848093bbd31cf4d0 Mon Sep 17 00:00:00 2001 From: Evan Shelhamer Date: Sat, 23 Aug 2014 19:25:56 -0700 Subject: [PATCH] move {InnerProduct,Eltwise}Layer to common instead of vision --- include/caffe/common_layers.hpp | 64 +++++++++++++++++++++++++++++++++++++++++ include/caffe/vision_layers.hpp | 64 ----------------------------------------- 2 files changed, 64 insertions(+), 64 deletions(-) diff --git a/include/caffe/common_layers.hpp b/include/caffe/common_layers.hpp index 979fd9a..ed47dbc 100644 --- a/include/caffe/common_layers.hpp +++ b/include/caffe/common_layers.hpp @@ -86,6 +86,37 @@ class ConcatLayer : public Layer { int concat_dim_; }; +/* EltwiseLayer + Compute elementwise operations like product or sum. +*/ +template +class EltwiseLayer : public Layer { + public: + explicit EltwiseLayer(const LayerParameter& param) + : Layer(param) {} + virtual void LayerSetUp(const vector*>& bottom, + vector*>* top); + + virtual inline LayerParameter_LayerType type() const { + return LayerParameter_LayerType_ELTWISE; + } + virtual inline int MinBottomBlobs() const { return 2; } + virtual inline int ExactNumTopBlobs() const { return 1; } + + protected: + virtual void Forward_cpu(const vector*>& bottom, + vector*>* top); + virtual void Forward_gpu(const vector*>& bottom, + vector*>* top); + virtual void Backward_cpu(const vector*>& top, + const vector& propagate_down, vector*>* bottom); + virtual void Backward_gpu(const vector*>& top, + const vector& propagate_down, vector*>* bottom); + + EltwiseParameter_EltwiseOp op_; + vector coeffs_; +}; + /* FlattenLayer */ template @@ -115,6 +146,39 @@ class FlattenLayer : public Layer { int count_; }; +/* InnerProductLayer +*/ +template +class InnerProductLayer : public Layer { + public: + explicit InnerProductLayer(const LayerParameter& param) + : Layer(param) {} + virtual void LayerSetUp(const vector*>& bottom, + vector*>* top); + + virtual inline LayerParameter_LayerType type() const { + return LayerParameter_LayerType_INNER_PRODUCT; + } + virtual inline int ExactNumBottomBlobs() const { return 1; } + virtual inline int ExactNumTopBlobs() const { return 1; } + + protected: + virtual void Forward_cpu(const vector*>& bottom, + vector*>* top); + virtual void Forward_gpu(const vector*>& bottom, + vector*>* top); + virtual void Backward_cpu(const vector*>& top, + const vector& propagate_down, vector*>* bottom); + virtual void Backward_gpu(const vector*>& top, + const vector& propagate_down, vector*>* bottom); + + int M_; + int K_; + int N_; + bool bias_term_; + Blob bias_multiplier_; +}; + /* MVNLayer */ template diff --git a/include/caffe/vision_layers.hpp b/include/caffe/vision_layers.hpp index d2d9ab3..02f9e43 100644 --- a/include/caffe/vision_layers.hpp +++ b/include/caffe/vision_layers.hpp @@ -60,37 +60,6 @@ class ConvolutionLayer : public Layer { int N_; }; -/* EltwiseLayer - Compute elementwise operations like product or sum. -*/ -template -class EltwiseLayer : public Layer { - public: - explicit EltwiseLayer(const LayerParameter& param) - : Layer(param) {} - virtual void LayerSetUp(const vector*>& bottom, - vector*>* top); - - virtual inline LayerParameter_LayerType type() const { - return LayerParameter_LayerType_ELTWISE; - } - virtual inline int MinBottomBlobs() const { return 2; } - virtual inline int ExactNumTopBlobs() const { return 1; } - - protected: - virtual void Forward_cpu(const vector*>& bottom, - vector*>* top); - virtual void Forward_gpu(const vector*>& bottom, - vector*>* top); - virtual void Backward_cpu(const vector*>& top, - const vector& propagate_down, vector*>* bottom); - virtual void Backward_gpu(const vector*>& top, - const vector& propagate_down, vector*>* bottom); - - EltwiseParameter_EltwiseOp op_; - vector coeffs_; -}; - /* Im2colLayer */ template @@ -125,39 +94,6 @@ class Im2colLayer : public Layer { int pad_h_, pad_w_; }; -/* InnerProductLayer -*/ -template -class InnerProductLayer : public Layer { - public: - explicit InnerProductLayer(const LayerParameter& param) - : Layer(param) {} - virtual void LayerSetUp(const vector*>& bottom, - vector*>* top); - - virtual inline LayerParameter_LayerType type() const { - return LayerParameter_LayerType_INNER_PRODUCT; - } - virtual inline int ExactNumBottomBlobs() const { return 1; } - virtual inline int ExactNumTopBlobs() const { return 1; } - - protected: - virtual void Forward_cpu(const vector*>& bottom, - vector*>* top); - virtual void Forward_gpu(const vector*>& bottom, - vector*>* top); - virtual void Backward_cpu(const vector*>& top, - const vector& propagate_down, vector*>* bottom); - virtual void Backward_gpu(const vector*>& top, - const vector& propagate_down, vector*>* bottom); - - int M_; - int K_; - int N_; - bool bias_term_; - Blob bias_multiplier_; -}; - // Forward declare PoolingLayer and SplitLayer for use in LRNLayer. template class PoolingLayer; template class SplitLayer; -- 2.7.4