a set of C++ library classes
for neural networks development



class ThreeLayer

MLP with two hidden layers - HTML documentation under construction.

Inheritance:


Public Methods

[more] ThreeLayer ()
[more] ThreeLayer (unsigned nout, unsigned nhidden1, unsigned nhidden2, unsigned nin, act_func fout=sigmoid, act_func fhid1=sigmoid, act_func fhid2=sigmoid)
[more] ~ThreeLayer ()
[more]void init_weights_norm (int seed = 0)
[more]void init_weights_const (double x)
[more]void print_weights (void)
[more]vect& compute (vect& vinput)
[more]void backprop (vect& t, vect& x)
[more]void print_info_grad (void)
[more]void save_weights (char* namefile)

Protected Fields

[more]unsigned n_hidden2

Protected Methods

[more]virtual void save_weights_heading (char* namefile)
It saves onto a file the general paramenters of the net
It saves the number of layers, size of the layers and type of the activation function
[more]virtual void save_weights_heading (ofstream& f, char* namebuf)
It saves in a stream the general paramenters of the net
It saves the number of layers, size of the layers and type of the activation function
[more]virtual void save_weights_body (char* namefile)
It appends onto a file the weights of the net.
[more]virtual void save_weights_body (ofstream& f)
It appends to a stream the weights of the net.


Inherited from TwoLayer:

Public Methods

oinline unsigned Nhidden1() const

Protected Fields

ounsigned n_hidden1


Inherited from OneLayer:

Public Fields

ostatic const double SIG_OFF
ostatic const double SIG_TRESHOLD
ostatic const double TANH_ON
ostatic const double TANH_OFF
ostatic const double TANH_TRESHOLD
ostatic const double ID_ON
ostatic const double ID_OFF
ostatic const double ID_TRESHOLD

Public Methods

ovirtual void read_weights(char* namefile)
ovirtual unsigned predictclassWTA(vect& vinput)
ovirtual unsigned predictclass(vect& vinput)
ovoid print_C(void)
oinline queue<float> & read_qerror()
ovoid save_errors(char* file)
ovirtual stop_cond Learn_by_pattern(TrainingSet& t_set, Learning& learn, unsigned& iter, double& error, double errtol = ERR_TOL, unsigned maxits = MAXITS, bool printout = true)
ovirtual stop_cond Learn_by_epoch(TrainingSet& t_set, Learning& learn, unsigned& iter, double& error, double errtol = ERR_TOL, unsigned maxits = MAXITS, bool printout = true)
omatrix test(TrainingSet& tset)
omatrix test(TrainingSet& tset, deque<unsigned>& outputs)
ovirtual void save_out(TrainingSet& tset, char* file)
ovoid save_out(TrainingSet& tset, ofstream& f)
ovoid save_predicted(deque<unsigned>& outputs, char* file)
ovoid save_decomp_matrix(ofstream& f)
oint CrossValidate(char* name, unsigned nfold, unsigned num_attr, char* filerr, LearnType& learninfo, char* savecvfile = "", char* readcvfile = "", char* outfile = "", int saveout = 0, int seed=0, bool printout=true)
ovirtual int CrossValidateTrialWeights(char* name, unsigned nfold, unsigned num_attr, char* filerr, LearnType& learninfo, char* outfile = "", int saveout = 0, int seed=0, int times=3, bool printout=true)
ovoid SaveCV(char* name, vector<unsigned>& iter, vect& abserr, vect& percerr, unsigned ntrain, matrix& conf, clock_t start, clock_t end)
ovoid print_resultCV(vector<unsigned>& iter, vect& abserr, vect& percerr, unsigned ntrain, clock_t start, clock_t end)
ovoid print_errors()
ounsigned Code_act_fun(act_func g)
oact_func Decode_act_fun(unsigned fun)
oint Read_seed(void)
odouble get_perc_errors(void)
ounsigned Read_minHam(void)

Public Members

o Activation, deactivation and threshold values with respectively sigmoid, hyperbolic tangent

Protected Fields

ostatic const unsigned ERR_PRECISION
ostatic const unsigned OUTPUT_PRECISION
ostatic const unsigned MAXITS
ostatic const double ERR_TOL
ostatic const unsigned INTEST_SIZE
ounsigned n_class
omatrix C
oLayerNetTrain layer[MAXLAYERS]
oqueue<float> Qerror
ounsigned num_errors
odouble perc_errors
oint seed
ounsigned minHam

Protected Methods

ovirtual void Init_C(void)
ovoid analyze(act_func g, double& on, double& off)
odouble Calc_square_error(vect& t, vect& out)
odouble calc_denom_RMS(vect& t, unsigned n_train)
odouble RMS_error(double err, double denom)
ovoid read_weights(istream& f)
ovoid save_weights_cv_heading(char* savecvfile, int nfold)
ovoid save_weights_cv_body(char* namefile, int fold_n)
ovoid do_Sum_deltas(unsigned n_layers, matrix* Sum_Delta_W[], vect* Sum_delta_bias[])
ovoid Update_Sum_Delta(unsigned n_layers, matrix* Sum_Delta_W[], vect* Sum_delta_bias[])
ovoid Zero(unsigned n_layers)
ovoid Zero_Sum_Delta(unsigned n_layers, matrix* Sum_Delta_W[], vect* Sum_delta_bias[])
ovoid Build_Sum_Delta(matrix* Sum_Delta_W[], vect* Sum_delta_bias[])
ovoid Delete_Sum_Delta(matrix* Sum_Delta_W[], vect* Sum_delta_bias[])
ovoid Copy_Sum_Delta_To_Delta(unsigned n_layers, LayerNetTrain layer[], matrix* Sum_Delta_W[], vect* Sum_delta_bias[])
ovirtual unsigned computeclassWTA(vect& out)
ovirtual unsigned computeclass(vect& out)


Inherited from Network:

Public Fields

ostatic const char* const NET_EXT
ostatic const char* const NETCV_EXT
ostatic const char* const ERR_EXT
ostatic const char* const OUT_EXT
ostatic const unsigned OUTPUT
ostatic const unsigned HIDDEN1
ostatic const unsigned HIDDEN2
ostatic const char* const CV_SUFFIX

Public Methods

oinline unsigned Nlayers() const
oinline unsigned Ninput() const
oinline unsigned Noutput() const

Protected Fields

ounsigned n_layers
ounsigned n_inputs
ounsigned n_outputs


Documentation

Three-Layer Perceptron
It Implemets a Three-Layer Perceptron for classification with learning capabilities
o ThreeLayer()

o ThreeLayer(unsigned nout, unsigned nhidden1, unsigned nhidden2, unsigned nin, act_func fout=sigmoid, act_func fhid1=sigmoid, act_func fhid2=sigmoid)

o ~ThreeLayer()

ovoid init_weights_norm(int seed = 0)

ovoid init_weights_const(double x)

ovoid print_weights(void)

ovect& compute(vect& vinput)

ovoid backprop(vect& t, vect& x)

ovoid print_info_grad(void)

ovoid save_weights(char* namefile)

ounsigned n_hidden2

ovirtual void save_weights_heading(char* namefile)
It saves onto a file the general paramenters of the net
It saves the number of layers, size of the layers and type of the activation function
Parameters:
- namefile name of the file for saving the net. The suffix net. is appended to namefile
See Also:
save_weights

ovirtual void save_weights_heading(ofstream& f, char* namebuf)
It saves in a stream the general paramenters of the net
It saves the number of layers, size of the layers and type of the activation function
Parameters:
f - streamfile for saving the net. Used by save_weights_heading(char* namefile).
namebuf - name of the file for saving the net.
See Also:
save_weights

ovirtual void save_weights_body(char* namefile)
It appends onto a file the weights of the net.
Parameters:
- namefile name of the file for saving the net. The suffix net. is appended to namefile
See Also:
save_weights

ovirtual void save_weights_body(ofstream& f)
It appends to a stream the weights of the net.
Parameters:
f - name stream file for saving the net. Used by save_weights_body(char* namefile).
See Also:
save_weights


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java


Last Updated February 2001
For comments and suggestions mail to Giorgio Valentini