28 #include "parametersettable.h"
29 #include "simpletimer.h"
36 #include <QStringList>
44 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
45 #pragma GCC diagnostic push
46 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
48 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
52 #include "Eigen/Dense"
55 #if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
56 #pragma GCC diagnostic pop
58 #pragma GCC diagnostic warning "-Wunused-local-typedefs"
82 static const int MAXSTOREDACTIVATIONS = 100;
84 static const int MAXN = 1000;
111 static void describe( QString type );
120 void create_net_block(
int inputNeuronType,
int hiddenNeuronType,
int outputNeuronType,
bool recurrentHiddens,
bool inputOutputConnections,
bool recurrentOutputs,
bool biasOnHidden,
bool biasOnOutput );
126 int load_net_blocks(
const char *filename,
int mode);
127 void save_net_blocks(
const char *filename,
int mode);
128 void readNewPheLine(QStringList,
float*,
float*);
129 void readOldPheLine(QStringList,
float*,
float*);
131 void computeParameters();
132 int setInput(
int inp,
float value);
133 float getOutput(
int out);
134 float getInput(
int in);
135 float getHidden(
int h);
137 int freeParameters();
138 float getFreeParameter(
int i);
139 void setParameters(
const int* dt);
140 void getMutations(
float* mut);
141 void copyPheParameters(
int* pheGene);
143 int getParamBias(
int nbias);
145 void injectHidden(
int nh,
float val);
146 float logistic(
float f);
152 float getNeuron(
int in);
153 bool pheFileLoaded();
155 char neuronl[MAXN][10];
156 int neurondisplay[MAXN];
157 double neuronrange[MAXN][2];
158 QColor neurondcolor[MAXN];
159 bool neuronlesion[MAXN];
160 float neuronlesionVal[MAXN];
161 void setRanges(
double weight,
double bias,
double gain);
172 float* getOldestStoredActivations();
184 float tansig(
float f);
187 bool inTraining() {
return training; };
189 void initWeightsInRange(
float min,
float max);
190 void initWeightsNguyenWidrow(
float min,
float max);
193 void prepareForTraining(QVector<float>& err_w);
196 float computeMeanSquaredError(QVector<float> trainingSet, QVector<float> desiredOutput);
197 float trainLevembergMarquardt(QVector<float> trainingSet, QVector<float> desiredOutput,
float maxError);
198 float trainLevembergMarquardtThroughTime(QVector<float> trainingSet, QVector<float> desiredOutput,
int time,
float maxError);
201 int extractWeightsFromNet(Eigen::VectorXf& w);
202 int importWeightsFromVector(Eigen::VectorXf& w);
203 int importWeightsFromMATLABFile(
char *path);
204 int exportWeightsToMATLABFile(
char *path);
205 float getWeight(
int to,
int from);
206 void setWeight(
int to,
int from,
float w);
208 void setNeckReflex();
210 int isHidden(
int neuron);
211 float derivative(
int n,
float x);
215 int n_outputsToTrain;
216 char *outputsToTrain;
218 char **trainingHiddenBlock;
220 QVector<float> err_weights;
221 float err_weight_sum;
230 int net_block[MAXN][6];
231 int neuronbias[MAXN];
232 int neurontype[MAXN];
233 int neurongain[MAXN];
234 int neuronxy[MAXN][2];
244 float storedActivations[MAXSTOREDACTIVATIONS][MAXN];
245 int nextStoredActivation;
246 int firstStoredActivation;
248 float netinput[MAXN];