22 #ifndef SINGA_NEURALNET_NEURALNET_H_
23 #define SINGA_NEURALNET_NEURALNET_H_
30 #include "proto/job.pb.h"
31 #include "neuralnet/layer.h"
32 #include "utils/factory.h"
33 #include "utils/graph.h"
39 using std::shared_ptr;
61 static shared_ptr<NeuralNet>
Create(
const NetProto& np, Phase phase,
int num);
69 explicit NeuralNet(NetProto netproto,
int npartitions = 1);
80 const std::vector<Layer*>& layers() {
83 const std::vector<ParserLayer*>& parserlayers()
const {
84 LOG(FATAL)<<
" not implemented";
87 const std::vector<LossLayer*>& losslayers()
const {
88 LOG(FATAL)<<
" not implemented";
91 const std::vector<DataLayer*>& datalayers()
const {
92 LOG(FATAL)<<
" not implemented";
95 const std::vector<Param*>& params()
const {
98 Layer* name2layer(
string name)
const {
99 if (name2layer_.find(name) != name2layer_.end())
100 return name2layer_.at(name);
104 Param* paramid2param(
int id)
const {
105 return paramid2param_.at(
id);
129 vector<Layer*> layers_;
130 vector<ParserLayer*> parserlayers_;
131 vector<LossLayer*> losslayers_;
132 vector<DataLayer*> datalayers_;
133 vector<Param*> params_;
135 map<string, Layer*> name2layer_;
136 map<int, Param*> paramid2param_;
139 #endif // SINGA_NEURALNET_NEURALNET_H_
void PrepareDataStructures()
prepare data structures, e.g., params_, layers_, etc.
static shared_ptr< NeuralNet > Create(const NetProto &np, Phase phase, int num)
Create the neural network for training, test or validation.
Base paramter class.
Definition: param.h:93
Graph * CreateGraph(const NetProto &netproto, int npartitions)
Create a neural net graph, one node for each layer.
void ShareParamsFrom(shared_ptr< NeuralNet > other)
Share memory of parameter values from other neuralnet.
NeuralNet(NetProto netproto, int npartitions=1)
construct the net structure from protocol buffer.
std::string ToAdjacency()
To display the adjacency layers.
Base layer class.
Definition: layer.h:44
Neuralnet is constructed by creating a graph with each node representing one layer at first...
Definition: graph.h:72
void CreateNetFromGraph(Graph *graph, int npartitions)
Create neural net from graph, one layer per node.
The neural network is constructed from user configurations in NetProto.
Definition: neuralnet.h:48