/usr/include/caffe/layers/concat_layer.hpp is in libcaffe-cpu-dev 1.0.0~rc4-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | #ifndef CAFFE_CONCAT_LAYER_HPP_
#define CAFFE_CONCAT_LAYER_HPP_
#include <vector>
#include "caffe/blob.hpp"
#include "caffe/layer.hpp"
#include "caffe/proto/caffe.pb.h"
namespace caffe {
/**
* @brief Takes at least two Blob%s and concatenates them along either the num
* or channel dimension, outputting the result.
*/
template <typename Dtype>
class ConcatLayer : public Layer<Dtype> {
public:
explicit ConcatLayer(const LayerParameter& param)
: Layer<Dtype>(param) {}
virtual void LayerSetUp(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
virtual void Reshape(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
virtual inline const char* type() const { return "Concat"; }
virtual inline int MinBottomBlobs() const { return 1; }
virtual inline int ExactNumTopBlobs() const { return 1; }
protected:
/**
* @param bottom input Blob vector (length 2+)
* -# @f$ (N \times C \times H \times W) @f$
* the inputs @f$ x_1 @f$
* -# @f$ (N \times C \times H \times W) @f$
* the inputs @f$ x_2 @f$
* -# ...
* - K @f$ (N \times C \times H \times W) @f$
* the inputs @f$ x_K @f$
* @param top output Blob vector (length 1)
* -# @f$ (KN \times C \times H \times W) @f$ if axis == 0, or
* @f$ (N \times KC \times H \times W) @f$ if axis == 1:
* the concatenated output @f$
* y = [\begin{array}{cccc} x_1 & x_2 & ... & x_K \end{array}]
* @f$
*/
virtual void Forward_cpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
virtual void Forward_gpu(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top);
/**
* @brief Computes the error gradient w.r.t. the concatenate inputs.
*
* @param top output Blob vector (length 1), providing the error gradient with
* respect to the outputs
* -# @f$ (KN \times C \times H \times W) @f$ if axis == 0, or
* @f$ (N \times KC \times H \times W) @f$ if axis == 1:
* containing error gradients @f$ \frac{\partial E}{\partial y} @f$
* with respect to concatenated outputs @f$ y @f$
* @param propagate_down see Layer::Backward.
* @param bottom input Blob vector (length K), into which the top gradient
* @f$ \frac{\partial E}{\partial y} @f$ is deconcatenated back to the
* inputs @f$
* \left[ \begin{array}{cccc}
* \frac{\partial E}{\partial x_1} &
* \frac{\partial E}{\partial x_2} &
* ... &
* \frac{\partial E}{\partial x_K}
* \end{array} \right] =
* \frac{\partial E}{\partial y}
* @f$
*/
virtual void Backward_cpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
virtual void Backward_gpu(const vector<Blob<Dtype>*>& top,
const vector<bool>& propagate_down, const vector<Blob<Dtype>*>& bottom);
int count_;
int num_concats_;
int concat_input_size_;
int concat_axis_;
};
} // namespace caffe
#endif // CAFFE_CONCAT_LAYER_HPP_
|