📄 neuron.h
字号:
/* YAKS, Optann, a Khepera simulator including a separate GA and ANN (Genetic Algoritm, Artificial Neural Net). Copyright (C) 2000 Johan Carlsson (johanc@ida.his.se) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */#ifndef NEURON_H#define NEURON_H#include <stdlib.h>#include <stdio.h>#include <iostream.h>#include <math.h>#ifdef LINUX#include <stdint.h>#else#include <inttypes.h>#endiftypedef enum {INTERN,OUTPUT,INPUT,BIAS,SCN}NODE_T;typedef enum {NORMAL,NULLAD,SCN_L}LINK_TO_T;typedef enum {SIGMOID,STEP,LINEAR,NONE,LOGISTIC,TANH}ACTIVATION_T;typedef struct{ int8_t weight; double *value; class Neuron *fromNode; class Neuron *toNode; class Neuron *SCN; long int fromId; long int toId; long int SCNid; LINK_TO_T typ; double slowness;}LINK_T;/** @class Neuron neuron.h * @brief The class implements a Neural Net neuron. * * @see Ann */class Neuron{ public: Neuron(int iLayerPriority,NODE_T inType,ACTIVATION_T iFuncT); Neuron(int iLayerPriority,NODE_T inType,ACTIVATION_T iFuncT,long int iId); ~Neuron(); class Neuron* duplicate(); void mutateWeights(int percentOfBits); void mutateWeightsWithPri(int bitMutateProbability, int pri); int getPriority(); double* activationPointer(); void createLink(class Neuron *toNeuron, int8_t iWeight,LINK_TO_T iType); void removeLink(int index); void removeLinksTo(class Neuron *toNeuron); void removeLinksTo(long int toNeuron); void correctAllLinksFrom(class Neuron *toNeuron); long int getId(); NODE_T getNodeType(); ACTIVATION_T getActFunc(); int8_t getLinkWeight(int index); int8_t *getLinkWeightPointer(int index); LINK_TO_T getLinkType(int index) const; long int getLinkToId(int index); long int getNextLinkId(); long int getLinkSCNid(int index); int getNrOfLinks(); void setLinkWeight(int index, int8_t iweight); void activate(); double getActivationValue(); void setActivationValue(double iValue); int getWriteActivation(); int SCNNotUsed() const; void createSCNLink(class Neuron *toNeuron,class Neuron *SCNNeuron); private: void setSCNUsed(); double sigmoid(double in); double step(double in); double linear(double in); double logistic(double in); LINK_T **links; ACTIVATION_T actType; NODE_T nType; int nrOfLinks; int layerPriority; double *activationValue; double inValue; long int id; int linkCount; int scnUsed;};#endif /* NEURON_N */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -