00001 #ifndef _NNETZ_H
00002 #define _NNETZ_H
00003
00004 #include <iostream>
00005 #include <fstream>
00006 using namespace std;
00007
00008 typedef struct networkTrainingResults {
00009 unsigned long int total_epochs, last_epochs, max_epochs;
00010 double error, trainError;
00011
00012
00013 networkTrainingResults () {
00014 this->total_epochs = 0;
00015 this->error = 0.0;
00016 this->trainError = 0.0;
00017 this->last_epochs = 0;
00018 this->max_epochs = 0;
00019 }
00020
00021 } NETWORKTRAININGRESULTS;
00022
00023
00024 class Network {
00025
00026 private:
00027
00028 float connection_rate;
00029 float learning_rate_eta;
00030 unsigned int num_input;
00031 unsigned int num_output;
00032 unsigned int num_layers;
00033 unsigned int num_neurons_hidden;
00034 unsigned int *hidden_neurons;
00035 float desired_error;
00036 unsigned int max_iterations;
00037 unsigned int iterations_between_reports;
00038 unsigned int dataCount;
00039 double activation_stepness_hidden;
00040 double activation_stepness_output;
00041 int activation_function_hidden;
00042 int activation_function_output;
00043 char dataFilename[30];
00044 char networkFilename[30];
00045 FILE* dataFile;
00046 struct fann *ann;
00047 double minInputValue;
00048 double maxInputValue;
00049 double minOutputValue;
00050 double maxOutputValue;
00051
00053 double normIn(double _in);
00054
00056 double normOut(double _out);
00057
00059 double reNormOut(double _out);
00060
00061 public:
00063 Network(int _num_input, int _num_output, int _num_layers, int _num_neurons_hidden, const char* _netName);
00065 ~Network();
00066
00068 void setMinMaxInputOutputValues (double _minInput, double _maxInput, double _minOutput, double _maxOutput);
00069
00071 void setParameters(int _max_epochs, int _iterations_between_report, double _desired_error, double _dEta, double _activation_stepness_hidden, double _activation_stepness_output, int _activation_function_hidden, int _activation_function_output);
00072
00074 void setDesiredError(double _desired_error);
00075
00077 void createNewTrainingDataFile();
00078
00080 void addTrainingData(double _in[], double _out[]);
00081
00083 void trainNet( NETWORKTRAININGRESULTS* _results);
00084
00086 void getNetValue(double _in[], double _out[]);
00087
00089 void clear();
00090 };
00091
00092 #endif