Simd Library Documentation.

Home | Release Notes | Download | Documentation | Forum | SourceForge | GitHub
Network Class Reference

Network class. More...

Public Member Functions

 Network ()
 Creates a new object of Network class. More...
 
void Clear ()
 Clears all layers of the neural network.
 
bool Add (Layer *layer)
 Adds new Layer to the neural network. More...
 
const IndexInputIndex () const
 Gets dimensions of input data. More...
 
const IndexOutputIndex () const
 Gets dimensions of output data. More...
 
template<class Logger >
bool Train (const Vectors &src, const Labels &dst, const TrainOptions &options, Logger logger)
 Trains the neural network. More...
 
template<class Logger >
bool Train (const Vectors &src, const Vectors &dst, const TrainOptions &options, Logger logger)
 Trains the neural network. More...
 
SIMD_INLINE const VectorPredict (const Vector &x, Layer::Method method=Layer::Fast)
 Classifies given sample. More...
 
bool Load (std::ifstream &ifs, bool train=false)
 Loads the neural network from file stream. More...
 
bool Load (const std::string &path, bool train=false)
 Loads the neural network from file. More...
 
bool Save (std::ofstream &ofs, bool train=false) const
 Saves the neural network to file stream. More...
 
bool Save (const std::string &path, bool train=false) const
 Saves the neural network to file. More...
 
void Convert (const Labels &src, Vectors &dst) const
 Converts format of classification results. More...
 

Detailed Description

Network class.

Class Network provides functionality for construction, loading, saving, prediction and training of convolutional neural network.

Constructor & Destructor Documentation

Network ( )

Creates a new object of Network class.

Creates empty network without any layers.

Member Function Documentation

bool Add ( Layer layer)

Adds new Layer to the neural network.

Parameters
[in]layer- a pointer to the new layer. You can add ConvolutionalLayer, MaxPoolingLayer and FullyConnectedLayer.
Returns
a result of addition. If added layer is not compatible with previous layer the result might be negative.
const Index& InputIndex ( ) const

Gets dimensions of input data.

Returns
a dimensions of input data.
const Index& OutputIndex ( ) const

Gets dimensions of output data.

Returns
a dimensions of output data.
bool Train ( const Vectors src,
const Labels dst,
const TrainOptions options,
Logger  logger 
)

Trains the neural network.

Parameters
[in]src- a set of input training samples.
[in]dst- a set of classification results.
[in]options- an options of training process.
[in]logger- a functor to log training process.
Returns
a result of the training.
bool Train ( const Vectors src,
const Vectors dst,
const TrainOptions options,
Logger  logger 
)

Trains the neural network.

Parameters
[in]src- a set of input training samples.
[in]dst- a set of classification results.
[in]options- an options of training process.
[in]logger- a functor to log training process.
Returns
a result of the training.
SIMD_INLINE const Vector& Predict ( const Vector x,
Layer::Method  method = Layer::Fast 
)

Classifies given sample.

Parameters
[in]x- an input sample.
[in]method- a method of prediction. By default it is equal to Layer::Fast.
Returns
a result of classification (vector with predicted probabilities).
bool Load ( std::ifstream &  ifs,
bool  train = false 
)

Loads the neural network from file stream.

Note
The network has to be created previously with using of methods Clear/Add.
Parameters
[in]ifs- a input file stream.
[in]train- a boolean flag (True - if we need to load temporary training data, False - otherwise). By default it is equal to False.
Returns
a result of loading.
bool Load ( const std::string &  path,
bool  train = false 
)

Loads the neural network from file.

Note
The network has to be created previously with using of methods Clear/Add.
Parameters
[in]path- a path to input file.
[in]train- a boolean flag (True - if we need to load temporary training data, False - otherwise). By default it is equal to False.
Returns
a result of loading.
bool Save ( std::ofstream &  ofs,
bool  train = false 
) const

Saves the neural network to file stream.

Parameters
[out]ofs- a output file stream.
[in]train- a boolean flag (True - if we need to save temporary training data, False - otherwise). By default it is equal to False.
Returns
a result of saving.
bool Save ( const std::string &  path,
bool  train = false 
) const

Saves the neural network to file.

Parameters
[in]path- a path to output file.
[in]train- a boolean flag (True - if we need to save temporary training data, False - otherwise). By default it is equal to False.
Returns
a result of saving.
void Convert ( const Labels src,
Vectors dst 
) const

Converts format of classification results.

Parameters
[in]src- a set of class indexes.
[out]dst- a set of vectors with predicted probabilities.