The core class of MCPN library, neural network itself. More...
#include <Neural_Net.h>
Classes | |
struct | Layer_Configuration_Item |
This structure is used to initialize network with random weights providing general configuration of each network layer. More... | |
class | Layer_Descriptor |
Defines a layer of neurons in the network for operating mode. More... | |
Public Types | |
enum | Mode { Operating = 0, Training } |
Network mode, could be either Training or Operating. More... | |
enum | Weights_Optimization_Methods { No_Optimization, Nguyen_Widrow } |
On weights initialization some optimization could be applied to reduce the time spent on training. More... | |
Public Member Functions | |
Neural_Net (const unsigned int number_of_threads=0) | |
Constructor, specify number of threads the net will use or construct without parameters to get threads count equal to number of CPU Cores. | |
~Neural_Net () | |
Destructor. | |
int | Read_Configuration (Simple_Stream< char > *stream) |
Reads configuration of the network - layer count, neuron weights, etc. from the provided stream. | |
int | Write_Configuration (Simple_Stream< char > *stream) |
Writes configuration of the network to the provided stream. Format itself is a sequence of numbers without sepa rators: total number of layers (int), number of inputs (int) followed by pairs of neurons count (int) and activation function index (int) per layer (order is from 1st layer to the output layer), the rest of configuration file are sets of weights (array, double) of neurons for each layer (again ordered from 1st layer to the output layer). | |
int | Set_Mode (Mode mode) |
Switch network mode to Training or Operating. After mode switch Propagate() should be called first. | |
int | Set_Input (const std::vector< double > &input) |
Copies from input to internal input buffer. Length = number of inputs in network configuration. | |
int | Set_Learning_Speed (const double learning_speed) |
Sets learning speed parameter of the network. | |
int | Get_Output (std::vector< double > &output) |
Copies from internal output buffer to output. | |
int | Set_Desired_Output (const std::vector< double > &desired_output) |
Fills in the desired response of the network to the provided input, used in training mode. | |
double | Get_Squared_Error () |
Calculates squared error of output for the latest propagated sample (not a mean error of the whole set). | |
int | Randomize_Weights (const std::vector< Layer_Configuration_Item > &layer_configuration, const int inputs_count, const Weights_Optimization_Methods method=No_Optimization, const Range weights_range=Range(-1, 1)) |
Deconstructs existing network if any and creates new with the provided layer configuration then randomizes weights for each layer using values from the provided range and optimization method if specified. | |
int | Propagate () |
Propagates input values through the network. Result of this operation is the formation of the network output vector that can be obtained using Get_Output() method. | |
int | Back_Propagate () |
Performs back propagation step when the network is in training mode. | |
Protected Attributes | |
Mutex | mutex_ |
Mutex that makes sure that only 1 thread is using Neural_Net object at a time. |
The core class of MCPN library, neural network itself.
enum Mode |