#include <SimdNeural.hpp>
Public Member Functions | |
Network () | |
Creates a new object of Network class. More... | |
void | Clear () |
Clears all layers of the neural network. | |
bool | Empty () const |
Returns true if the neural network is empty. | |
bool | Add (Layer *layer) |
Adds new Layer to the neural network. More... | |
const Index & | InputIndex () const |
Gets dimensions of input data. More... | |
const Index & | OutputIndex () 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... | |
void | SetThreadNumber (size_t number, bool train=false) |
Sets thread number. More... | |
SIMD_INLINE const Vector & | Predict (const Vector &x, size_t thread=0, Layer::Method method=Layer::Fast) |
Classifies given sample. More... | |
bool | Load (const void *data, size_t size, bool train=false) |
Loads the weights of neural network from an external buffer. More... | |
bool | Load (std::istream &is, bool train=false) |
Loads the weights of neural network from file stream. More... | |
bool | Load (const std::string &path, bool train=false) |
Loads the weights of neural network from file. More... | |
bool | Save (void *data, size_t *size, bool train=false) const |
Saves the weights of neural network into external buffer. More... | |
bool | Save (std::ostream &os, bool train=false) const |
Saves the weights of neural network to file stream. More... | |
bool | Save (const std::string &path, bool train=false) const |
Saves the weights of 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()
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.
◆ SetThreadNumber()
void SetThreadNumber | ( | size_t | number, |
bool | train = false |
||
) |
Sets thread number.
- Note
- Call this function if you want to call method Predict from dirrerent thread.
- Parameters
-
[in] number - a number of threads. [in] train - a train process boolean flag. By default it is equal to False.
◆ Predict()
SIMD_INLINE const Vector & Predict | ( | const Vector & | x, |
size_t | thread = 0 , |
||
Layer::Method | method = Layer::Fast |
||
) |
Classifies given sample.
- Parameters
-
[in] x - an input sample. [in] thread - a work thread number. By default it is equal to 0. [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/3]
bool Load | ( | const void * | data, |
size_t | size, | ||
bool | train = false |
||
) |
Loads the weights of neural network from an external buffer.
- Note
- The network has to be created previously with using of methods Clear/Add.
- Parameters
-
[in] data - a pointer to the external buffer. [in] size - a size of the external buffer. [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/3]
bool Load | ( | std::istream & | is, |
bool | train = false |
||
) |
Loads the weights of 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() [3/3]
bool Load | ( | const std::string & | path, |
bool | train = false |
||
) |
Loads the weights of 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/3]
bool Save | ( | void * | data, |
size_t * | size, | ||
bool | train = false |
||
) | const |
Saves the weights of neural network into external buffer.
- Parameters
-
[out] data - a pointer to the external buffer. [in,out] size - a pointer to the size of external buffer. Returns requred buffer size. [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/3]
bool Save | ( | std::ostream & | os, |
bool | train = false |
||
) | const |
Saves the weights of 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() [3/3]
bool Save | ( | const std::string & | path, |
bool | train = false |
||
) | const |
Saves the weights of 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.