Simd Library Documentation.

Home | Release Notes | Download | Documentation | Issues | GitHub | SourceForge
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::istream &is, 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::ostream &os, 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()

Network ( )

Creates a new object of Network class.

Creates empty network without any layers.

Member Function Documentation

◆ Add()

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.

◆ InputIndex()

const Index& InputIndex ( ) const

Gets dimensions of input data.

Returns
a dimensions of input data.

◆ OutputIndex()

const Index& OutputIndex ( ) const

Gets dimensions of output data.

Returns
a dimensions of output data.

◆ Train() [1/2]

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.

◆ Train() [2/2]

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.

◆ Predict()

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).

◆ Load() [1/2]

bool Load ( std::istream &  is,
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]is- a input 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.

◆ Load() [2/2]

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.

◆ Save() [1/2]

bool Save ( std::ostream &  os,
bool  train = false 
) const

Saves the neural network to file stream.

Parameters
[out]os- a output 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.

◆ Save() [2/2]

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.

◆ Convert()

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.