Visit the lwnnplus home page, download the technical report in english or italian.
#include <network.h>
Public Member Functions | |
network (int activ, int no_of_layers,...) | |
Constructor for a network. | |
network (int activ, vector< int > layers) | |
Constructor for a network. | |
network (const char *filename, bool binary=true) | |
Constructor. Load network from file. | |
network (const network &b) | |
Copy constructor. | |
~network () | |
Destructor. Free memory allocated for a network. | |
void | randomize (float range) |
Assign random values to all weights in the network. | |
float | get_momentum () const |
Retrieve the momentum of a network. | |
float | get_learning_rate () const |
Retrieve the momentum of a network. | |
int | get_no_of_inputs () const |
Retrieve the number of inputs of a network. | |
int | get_no_of_outputs () const |
Retrieve the number of outputs of a network. | |
int | get_no_of_layers () const |
Retrieve the number of layers of a network. | |
int | get_no_of_neurons (int l) const |
Retrieve number of neurons on a layer of a netwrwork. | |
float | get_weight (int l, int nl, int nu) const |
Retrieve a weight of a network. | |
int | get_no_of_patterns () const |
Retrieve the number of patterns in batch training. | |
int | get_activation () const |
Retrieve the activation function of network (network::LOGISTIC or network::TANH). | |
float | get_output_error () const |
Retrieve the output error of a network. | |
float | get_max_learning_rate () |
Retrieve maximum learning rate allowed in SuperSab mode. | |
float | get_min_learning_rate () |
Retrieve minimum learning rate allowed in SuperSab mode. | |
float | get_ssab_up_factor () |
Retrieve factor for increasing learning rate in SuperSab mode. | |
float | get_ssab_down_factor () |
Retrieve factor for decreasing learning rate in SuperSab mode. | |
void | set_learning_rate (float learning_rate) |
Change the learning rate of a network. | |
void | set_activation (int num_func) |
Set activation function of the network. | |
void | set_momentum (float momentum) |
Change the momentum of a network. | |
void | set_max_learning_rate (float max) |
Set maximum learning rate allowed in SuperSab mode. | |
void | set_min_learning_rate (float min) |
Set minimum learning rate allowed in SuperSab mode. | |
void | set_ssab_up_factor (float factor) |
Set factor for increasing learning rate in SuperSab mode. | |
void | set_ssab_down_factor (float factor) |
Set factor for decreasing learning rate in SuperSab mode. | |
void | save (const char *filename) const |
Write a network to a binary file. | |
void | load (const char *filename) |
Read a network from a binary file. | |
void | friendly_print (const bool show=false) const |
Write a network to stdout in a friendly format. | |
void | print () const |
Write a network to a stdout. | |
void | textsave (const char *filename) const |
Write a network to a text file. | |
void | textload (const char *filename) |
Read a network from a text file. | |
float | compute_output_error (const float *target) |
Compute the output error of a network. | |
float | compute_average_error (const float *target) const |
Compute the average error of a network. | |
float | compute_quadratic_error (const float *target) const |
Compute the quadratic error a network. | |
float | compute_max_error (const float *target) const |
Compute the max error a network. | |
void | compute (const float *input, float *output) |
Compute outputs of a network for given inputs. | |
void | train () |
Train a network. | |
bool | is_ssab_active () const |
True if ssab is active. | |
int | count_weights () const |
Count the number of weights of the network. | |
int | begin_ssab () |
Begin SuperSab mode setting the nus to learning rate of the network. | |
void | train_ssab () |
Train a network in ssab mode. | |
int | reset_ssab () |
Reset the values of learning rates of the network to learning_rate in SuperSab mode. | |
void | free_ssab () |
Free the memory used for SuperSab and end SuperSab mode. | |
bool | save_ssab (const char *filename) const |
Write SuperSab learning rates to a binary file. | |
bool | load_ssab (const char *filename) |
Load SuperSab learning rates from a binary file. | |
int | ssab_print_nus () const |
Print learning rates for SuperSab mode. | |
int | ssab_stats (float &average, float &max, float &min, int &n_max, int &n_min) |
Make some statistics about learning rates in SuperSab mode. | |
void | begin_batch () |
Begin training in batch mode. | |
void | train_batch () |
Train a network in batch mode. | |
void | end_batch () |
End training in batch mode adjusting weights. | |
void | end_batch_ssab () |
End training in batch mode adjusting weights with SuperSab. | |
void | jolt (float factor, float range) |
Make small random changes to the weight of a network. | |
const network & | operator= (const network &b) |
Overloaded operator=. | |
Static Public Attributes | |
const int | LOGISTIC = NET_LOGISTIC |
Public constant for the logistic function. | |
const int | TANH = NET_TANH |
Public constant for the tanh function. | |
Friends | |
ostream & | operator<< (ostream &, const network &) |
Write a network on a stream. |
|
Constructor for a network.
The parameters of the network are set to default values. (for example momentum is 0). You can change them later by the mutators methods. If no_of_layers < 2 throws a runtime_error exception |
|
Constructor for a network.
The parameters of the network are set to default values. (for example momentum is 0). You can change them later by the mutators methods. If layers.size() < 2 throws a runtime_error exception |
|
Constructor. Load network from file.
|
|
Assign random values to all weights in the network.
|
|
Retrieve the momentum of a network.
|
|
Retrieve the momentum of a network.
|
|
Retrieve the number of inputs of a network.
|
|
Retrieve the number of outputs of a network.
|
|
Retrieve the number of layers of a network.
|
|
Retrieve number of neurons on a layer of a netwrwork.
|
|
Retrieve a weight of a network.
|
|
Retrieve the number of patterns in batch training.
|
|
Retrieve the activation function of network (network::LOGISTIC or network::TANH).
|
|
Retrieve the output error of a network.
|
|
Retrieve maximum learning rate allowed in SuperSab mode.
|
|
Retrieve minimum learning rate allowed in SuperSab mode.
|
|
Retrieve factor for increasing learning rate in SuperSab mode.
|
|
Retrieve factor for decreasing learning rate in SuperSab mode.
|
|
Change the learning rate of a network.
|
|
Set activation function of the network.
|
|
Change the momentum of a network.
|
|
Set maximum learning rate allowed in SuperSab mode.
If the previous max learning rate was greater than the new one and SuperSab mode is active, all the learning rates are changed to make them lesser than the new maximum. So, if you just want to change default max learning rate, call this method before begin_ssab(). |
|
Set minimum learning rate allowed in SuperSab mode.
If the previous min learning rate was lesser than the new one and SuperSab mode is active, all the learning rates are changed to make them greater than the new minimum. So, if you just want to change default min learning rate, call this method before begin_ssab(). |
|
Set factor for increasing learning rate in SuperSab mode.
|
|
Set factor for decreasing learning rate in SuperSab mode.
|
|
Write a network to a binary file.
|
|
Read a network from a binary file.
|
|
Write a network to stdout in a friendly format.
|
|
Write a network to a text file.
|
|
Read a network from a text file.
|
|
Compute the output error of a network.
|
|
Compute the average error of a network.
|
|
Compute the quadratic error a network.
|
|
Compute the max error a network.
|
|
Compute outputs of a network for given inputs.
|
|
Train a network. Before calling this routine, compute() and compute_output_error() should have been called to compute outputs for given inputs and to prepare the neural network for training by computing the output error. This routine performs the actual training by backpropagating the output error through the layers. |
|
True if ssab is active.
|
|
Count the number of weights of the network.
|
|
Begin SuperSab mode setting the nus to learning rate of the network. Precondition: (! is_ssab_active()) i.e. begin_ssab was not called before. If is_ssab_active() and you want to reset the values of nus, use reset_ssab() or if you want to free memory used for SuperSab, use free_ssab()
|
|
Train a network in ssab mode. Before calling this routine, begin_ssab() should have been called to begin SuperSab training. Furthermore, for the current input/output pair, compute() and compute_output_error() should have been called to compute outputs for given inputs and to prepare the neural network for training by computing the output error. This routine performs the actual training by backpropagating the output error through the layers and changing the weights. The better way to use SuperSab is in combination with batch training, using train_batch() for the training and end_batch_ssab() at the end of every epoch. |
|
Reset the values of learning rates of the network to learning_rate in SuperSab mode. Precondition: is_ssab_active()
|
|
Free the memory used for SuperSab and end SuperSab mode. After the call of free_ssab, the values of learning rates are lost and SuperSab mode is off. |
|
Write SuperSab learning rates to a binary file.
|
|
Load SuperSab learning rates from a binary file.
|
|
Print learning rates for SuperSab mode.
|
|
Make some statistics about learning rates in SuperSab mode.
|
|
Train a network in batch mode. Before calling this routine, begin_batch() should have been called (at the start of the batch) to begin batch training. Furthermore, for the current input/target pair, compute() and compute_output_error() should have been called to compute outputs for given the inputs and to prepare the neural network for training by computing the output error using the given targets. This routine performs the actual training by backpropagating the output error through the layers, but does not change the weights. The weights will be changed when (at the end of the batch) end_batch() (or end_batch_ssab()) is called. |
|
End training in batch mode adjusting weights. Adjust the weights in the neural network according to the average delta of all patterns in the batch. |
|
End training in batch mode adjusting weights with SuperSab. Adjust the weights in the neural network according to the average delta of all patterns in the batch and with SuperSab. For using SuperSab mode in batch training you should call once begin_ssab(), then begin_batch() at the beginning of every epoch, train the network with train_batch() and then call end_batch_ssab() at the end of every epoch. |
|
Make small random changes to the weight of a network.
|
|
Write a network on a stream. Same format as friendly_print() (friendly_print(false) i.e. weights are not displayed) Usage: os << net; |