00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __PERCEPTRON_H__
00017 #define __PERCEPTRON_H__
00018
00019 #include "../Utilities/Vector.h"
00020
00021 namespace Flood
00022 {
00023
00026
00027 class Perceptron
00028 {
00029 public:
00030
00031
00032
00033 explicit Perceptron(void);
00034
00035
00036
00037 explicit Perceptron(int);
00038
00039
00040
00041 explicit Perceptron(int, double);
00042
00043
00044
00045 explicit Perceptron(const char*);
00046
00047
00048
00049 Perceptron(const Perceptron&);
00050
00051
00052
00053 virtual ~Perceptron(void);
00054
00055
00056
00057 Perceptron& operator = (const Perceptron&);
00058
00059
00060
00062
00063 enum ActivationFunction{Threshold, SymmetricThreshold, Logistic, HyperbolicTangent, Linear};
00064
00065
00066
00067
00068
00070
00071 inline int get_inputs_number(void)
00072 {
00073 return(inputs_number);
00074 } ActivationFunction& get_activation_function(void);
00075 std::string get_activation_function_name(void);
00076
00077 double get_bias(void);
00078
00079 Vector<double>& get_synaptic_weights(void);
00080 double get_synaptic_weight(int);
00081
00082 int get_parameters_number(void);
00083 Vector<double> get_parameters(void);
00084
00085 bool get_display(void);
00086
00087
00088
00089 void set(void);
00090 void set(int);
00091 void set(int, double);
00092 void set(const Perceptron&);
00093
00094 void set_inputs_number(int);
00095
00096 void set_activation_function(const ActivationFunction&);
00097 void set_activation_function(const std::string&);
00098
00099 void set_bias(double);
00100 void set_synaptic_weights(const Vector<double>&);
00101 void set_synaptic_weight(int, double);
00102
00103 void set_parameters(const Vector<double>&);
00104
00105 void set_display(bool);
00106
00107
00108
00109 void initialize_bias(double);
00110 void initialize_bias_uniform(double, double);
00111 void initialize_bias_normal(double, double);
00112
00113 void initialize_synaptic_weights(double);
00114 void initialize_synaptic_weights_uniform(double, double);
00115 void initialize_synaptic_weights_normal(double, double);
00116
00117 void initialize_parameters(double);
00118
00119
00120
00121 double calculate_combination(const Vector<double>&);
00122
00123
00124
00125 double calculate_activation(double);
00126 double calculate_activation_derivative(double);
00127 double calculate_activation_second_derivative(double);
00128
00129
00130
00131 double calculate_output(const Vector<double>&);
00132
00133
00134
00135 std::string to_XML(bool);
00136
00137 void print(void);
00138
00139 void save(const char*);
00140 void load(const char*);
00141
00142 private:
00143
00144
00145
00147
00148 ActivationFunction activation_function;
00149
00151
00152 int inputs_number;
00153
00155
00156 double bias;
00157
00159
00160 Vector<double> synaptic_weights;
00161
00163
00164 bool display;
00165
00166
00167
00168
00169
00170 double calculate_random_uniform(double, double);
00171 double calculate_random_normal(double, double);
00172 };
00173
00174 }
00175
00176 #endif
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195