1 #ifndef INCLUDE_NET_LAYER_H_
2 #define INCLUDE_NET_LAYER_H_
14 #include "proto/model.pb.h"
15 #include "utils/data_shard.h"
16 #include "neuralnet/base_layer.h"
42 const vector<int> &shape,
43 const vector<SLayer>& srclayers);
45 virtual void ComputeFeature(
bool training,
const vector<shared_ptr<Layer>>& srclayers);
46 virtual void ComputeGradient(
const vector<shared_ptr<Layer>>& srclayers);
48 return vector<shared_ptr<Param>>{weight_, bias_};
51 CHECK_LT(k, srclayers_.size());
55 int kernel_, pad_, stride_ ;
56 int batchsize_, channels_, height_,width_;
57 int col_height_, col_width_, conv_height_, conv_width_, num_filters_;
58 shared_ptr<Param> weight_, bias_;
73 const vector<int> &shape,
74 const vector<SLayer>& srclayers);
76 virtual void ComputeFeature(
bool training,
const vector<shared_ptr<Layer>>& srclayers);
77 virtual void ComputeGradient(
const vector<shared_ptr<Layer>>& srclayers);
104 const vector<int> &shape,
105 const vector<SLayer>& srclayers);
107 CHECK_LT(k, srclayers_.size());
111 virtual void ComputeFeature(
bool training,
const vector<shared_ptr<Layer>>& srclayers);
112 virtual void ComputeGradient(
const vector<shared_ptr<Layer>>& srclayers);
115 return vector<shared_ptr<Param>>{weight_, bias_};
124 shared_ptr<Param> weight_, bias_;
132 virtual void ParseRecords(
bool training,
const vector<Record>& records,
155 const vector<int> &shape,
156 const vector<SLayer>& srclayers);
159 virtual void ComputeFeature(
bool training,
const vector<shared_ptr<Layer>>& srclayers);
160 virtual void ComputeGradient(
const vector<shared_ptr<Layer>>& srclayers);
176 virtual void ParseRecords(
bool training,
const vector<Record>& records,
186 float gamma_, beta_, sigma_, kernel_, alpha_, norm_a_, norm_b_;
187 int resize_, elastic_freq_;
200 const vector<int> &shape,
201 const vector<SLayer>& srclayers);
202 virtual void ComputeFeature(
bool training,
const vector<shared_ptr<Layer>>& srclayers);
203 virtual void ComputeGradient(
const vector<shared_ptr<Layer>>& srclayers);
205 int kernel_, pad_, stride_;
206 int batchsize_,channels_, height_, width_, pooled_height_, pooled_width_;
207 PoolingProto_PoolMethod pool_;
221 const vector<int> &shape,
222 const vector<SLayer>& srclayers);
224 virtual void ComputeFeature(
bool training,
const vector<shared_ptr<Layer>>& srclayers);
225 virtual void ComputeGradient(
const vector<shared_ptr<Layer>>& srclayers);
243 const vector<int> &shape,
244 const vector<SLayer>& srclayers);
250 if(layer_proto_.partition_type()==kLayerPartition)
253 return layer_proto_.partition_type();
256 CHECK_LT(k, srclayers_.size());
260 virtual void ComputeFeature(
bool training,
const vector<shared_ptr<Layer>>& srclayers);
261 virtual void ComputeGradient(
const vector<shared_ptr<Layer>>& srclayers);
274 virtual void ParseRecords(
bool training,
const vector<Record>& records,
290 virtual void ComputeFeature(
bool training,
const vector<shared_ptr<Layer>>&
srclayers);
294 shared_ptr<DataShard> shard_;
302 virtual void ComputeFeature(
bool training,
const vector<shared_ptr<Layer>>&
srclayers);
305 void ConvertDatumToSingleLableImageRecord(
const Datum& datum,
312 MDB_cursor* mdb_cursor_;
313 MDB_val mdb_key_, mdb_value_;
332 const vector<int> &shape,
333 const vector<SLayer>& srclayers);
336 virtual void ComputeFeature(
bool training,
const vector<shared_ptr<Layer>>& srclayers);
337 virtual void ComputeGradient(
const vector<shared_ptr<Layer>>& srclayers);
339 float outer_scale_, inner_scale_;
345 #endif // INCLUDE_NET_LAYER_H_
int lsize_
size local response (neighbor) area
Definition: layer.h:165
parse the input records into Blobs.
Definition: base_layer.h:551
float alpha_
hyper-parameter
Definition: layer.h:167
virtual void ComputeGradient()
Compute gradients for parameters and connecting layers.
Definition: model.pb.h:3309
Definition: model.pb.h:1128
This layer apply Tan function to neuron activations.
Definition: layer.h:321
virtual void ParseRecords(bool training, const vector< Record > &records, Blob< float > *blob)
Parse records from DataLayer into blob.
virtual ConnectionType connection_type(int k) const
Return connection type between two layers.
Definition: layer.h:50
virtual ConnectionType connection_type(int k) const
Return connection type between two layers.
Definition: layer.h:106
int batchsize_
shape of the bottom layer feature
Definition: layer.h:163
virtual const vector< SLayer > srclayers() const
return LayerS that connected to this layer
Definition: base_layer.h:221
Definition: model.pb.h:3159
virtual void ComputeFeature(bool training, const vector< SLayer > &srclayers)=0
Compute features of this layer based on connected layers.
virtual void Setup()
Setup layer properties.
Base layer for reading records from local Shard, HDFS, lmdb, etc.
Definition: base_layer.h:375
virtual vector< shared_ptr< Param > > GetParams()
Layers that have paramters must overload this function.
Definition: layer.h:47
virtual ConnectionType connection_type(int k) const
Return connection type between two layers.
Definition: layer.h:255
virtual void ParseRecords(bool training, const vector< Record > &records, Blob< float > *blob)
Parse records from DataLayer into blob.
Loss layer to calculate loss and other metrics, e.g., precison.
Definition: base_layer.h:520
virtual void Setup()
Setup layer properties.
Definition: base_layer.h:577
virtual void ParseRecords(bool training, const vector< Record > &records, Blob< float > *blob)
Parse records from DataLayer into blob.
virtual void SetupAfterPartition()
Setup the layer properties except shape.
Base layer class.
Definition: base_layer.h:37
virtual void Setup()
Setup layer properties.
Definition: base_layer.h:390
fully connected layer
Definition: layer.h:90
Convolution layer.
Definition: layer.h:28
virtual PartitionType partition_type() const
softmax is not recommendeded for partition because it requires the whole src layer for normalization...
Definition: layer.h:249
virtual vector< shared_ptr< Param > > GetParams()
Layers that have paramters must overload this function.
Definition: layer.h:114