|
virtual void | Setup (const LayerProto &proto, int npartitions=1) |
| Setup layer properties. More...
|
|
virtual void | ComputeFeature (int flag, Metric *perf)=0 |
| Compute features of this layer based on connected layers. More...
|
|
virtual void | ComputeGradient (int flag, Metric *perf)=0 |
| Compute gradients for parameters and connected layers. More...
|
|
virtual const std::vector
< Param * > | GetParams () const |
| Layers that have paramters must override this function. More...
|
|
virtual ConnectionType | src_neuron_connection (int k) const |
| Return the connection type between one neuron of this layer and its source layer. More...
|
|
virtual ConnectionType | dst_layer_connection () const |
| Return the connection type of this layer and all dst layers. More...
|
|
virtual const std::string | DebugString (int step, int flag) |
| For print debug info about each layer, e.g., norm of feature vector, norm of parameters. More...
|
|
int | partition_dim () const |
|
int | partition_id () const |
|
int | type () const |
|
const std::string & | name () const |
| Return name of this layer.
|
|
virtual const Blob< float > & | data (const Layer *from) const |
|
virtual Blob< float > * | mutable_data (const Layer *from) |
|
virtual const Blob< float > & | grad (const Layer *from) const |
|
virtual Blob< float > * | mutable_grad (const Layer *from) |
|
const std::vector< Layer * > | srclayers () const |
| return LayerS that connected to this layer
|
|
const std::vector< Layer * > | dstlayers () const |
| return LayerS that this layer connected to
|
|
int | srclayers_size () const |
|
int | dstlayers_size () const |
|
void | clear_dstlayers () |
|
void | clear_srclayers () |
|
void | add_srclayer (Layer *src) |
|
void | add_dstlayer (Layer *dst) |
|
Base layer class.
Children should implement at least Layer::ComputeFeature() and Layer::ComputGradient() functions for contrastive-divergence/back-propagation algorithm.
virtual ConnectionType singa::Layer::dst_layer_connection |
( |
| ) |
const |
|
inlinevirtual |
Return the connection type of this layer and all dst layers.
Currently support two connection types: kOneToOne, and kOneToMany. kOneToOne indicates the users implement the ComputeFeature and ComputeGradient function considering only one dest layer. In this case, a SplitLayer will be added automatically to connect this layer with all dest layer. kOneToMany indicates the users has already considered multiple dest layers in the implementation.
- Returns
- connection type default is kOneToOne.
Reimplemented in singa::ParserLayer, and singa::DataLayer.
virtual void singa::Layer::Setup |
( |
const LayerProto & |
proto, |
|
|
int |
npartitions = 1 |
|
) |
| |
|
inlinevirtual |
Setup layer properties.
Setup the shapes for data and parameters, also setup some properties based on the layer configuration and connected layers.
- Parameters
-
proto | layer configuration. |
npartitions | num of total partitions of the original layer. This layer should be setup as one partition. |
Reimplemented in singa::RBMHidLayer, singa::RBMVisLayer, singa::RBMLayer, singa::SigmoidLayer, singa::RGBImageLayer, singa::STanhLayer, singa::MnistLayer, singa::LabelLayer, singa::InnerProductLayer, singa::SplitLayer, singa::ReLULayer, singa::CPoolingLayer, singa::SliceLayer, singa::PoolingLayer, singa::ConcateLayer, singa::ShardDataLayer, singa::DropoutLayer, singa::BridgeDstLayer, singa::SoftmaxLossLayer, and singa::ConvolutionLayer.
virtual ConnectionType singa::Layer::src_neuron_connection |
( |
int |
k | ) |
const |
|
inlinevirtual |
Return the connection type between one neuron of this layer and its source layer.
Currently support two connection types: kOneToOne, and kOneToAll. kOneToOne indicates the neuron depends on only one neuron from src layer. kOneToAll indicates the neuron depends on all neurons from src layer. TODO(wangwei) support kOneToMany.
- Parameters
-
k | index of source layer (current only support k = 0. |
connection | type. |
Reimplemented in singa::SoftmaxLossLayer, and singa::ConvolutionLayer.