Apache SINGA
A distributed deep learning platform .
 All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
singa::NeuralNet Class Reference

The neural network is constructed from user configured layers through google protocol buffer. More...

#include <neuralnet.h>

Public Member Functions

 NeuralNet (NetProto net_proto, int group_size=1)
 construct the net structure from protocol buffer.
 
std::string ToString ()
 construct a json string representing the neuralnet graph. More...
 
string DebugInfo ()
 Print Norm1 of data and grad of each Layer and parameter. More...
 
std::string ToAdjacency ()
 to display the adjacency layers
 
void AddLayer (const LayerProto &layer_proto)
 Add layer explicitly used in manually programming/constructing neural net.
 
void AddLayer (const Layer *layer)
 Add layer explicitly used in manually programming/constructing neural net.
 
void ShareParams (shared_ptr< NeuralNet > other, int flag)
 share weights from other neuralnet
 
void ToProto (NetProto *net_proto, bool copyData=false)
 
const std::vector< shared_ptr
< Layer > > & 
layers ()
 
const std::vector< ParserLayer * > & parserlayers ()
 return ParserLayer of the neuralnet.
 
const std::vector< LossLayer * > & losslayers ()
 
const std::vector< DataLayer * > & datalayers ()
 
const std::vector< shared_ptr
< Param > > & 
params () const
 
shared_ptr< Layername2layer (string name)
 
shared_ptr< Paramparamid2param (int id)
 

Static Public Member Functions

static void RegisterLayers ()
 Register Layers.
 
static shared_ptr< NeuralNetSetupNeuralNet (const NetProto &np, Phase phase, int group_size)
 Setup the neural network for training, test or validation. More...
 

Protected Member Functions

void ConstructNeuralNet (const NetProto &net_proto)
 
void PartitionNeuralNet ()
 
map< string, shared_ptr< Layer > > GetNameToLayer (const vector< shared_ptr< Layer >> &layers)
 
Graph CreatePartitonedGraph (const vector< shared_ptr< Layer >> &layers, const map< string, shared_ptr< Layer >> &name2layer)
 
map< string, vector
< shared_ptr< Layer > > > 
PartitionLayers (const vector< shared_ptr< Layer >> &layers)
 Partition each layer according its partition type and dimension. More...
 

Protected Attributes

vector< shared_ptr< Layer > > layers_
 
vector< ParserLayer * > parserlayers_
 
vector< LossLayer * > losslayers_
 
vector< DataLayer * > datalayers_
 
vector< shared_ptr< Param > > params_
 
map< string, shared_ptr< Layer > > name2layer_
 
map< int, shared_ptr< Param > > paramid2param_
 
map< string, LayerProtoname2layerproto_
 
int group_size_
 
Graph graph_
 

Detailed Description

The neural network is constructed from user configured layers through google protocol buffer.

TODO support constructing neural network by adding layers explicitly. E.g., users create layers and connect them manually in the code.

Some layers, e.g., SplitLayer and BridgeSrcLayer/BridgeDstLayer will be added implicitly to partition the neural network.

Member Function Documentation

string singa::NeuralNet::DebugInfo ( )

Print Norm1 of data and grad of each Layer and parameter.

Parameters
net,neuralnetwork
map<string, vector<shared_ptr<Layer> > > singa::NeuralNet::PartitionLayers ( const vector< shared_ptr< Layer >> &  layers)
protected

Partition each layer according its partition type and dimension.

Parameters
layersoriginal unpartitioned layers
static shared_ptr<NeuralNet> singa::NeuralNet::SetupNeuralNet ( const NetProto np,
Phase  phase,
int  group_size 
)
static

Setup the neural network for training, test or validation.

Parameters for test/validation net can share those from training after setup (done outside of this funcion).

Parameters
npproto for the neural network.
phasetest/training/validation
group_sizepartition the net among this num of workers
std::string singa::NeuralNet::ToString ( )

construct a json string representing the neuralnet graph.

The json string can be used by other graph engine to draw a figure for displaying the neuralnet structure.


The documentation for this class was generated from the following file: