2015-03-23 20:58:30 +00:00
|
|
|
#pragma once
|
|
|
|
|
2015-10-26 19:34:26 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
|
2015-03-23 20:58:30 +00:00
|
|
|
#include <vector>
|
2015-10-22 14:02:27 +00:00
|
|
|
#include <list>
|
2015-03-23 20:58:30 +00:00
|
|
|
|
2015-10-16 20:59:04 +00:00
|
|
|
class Layer;
|
|
|
|
|
2015-03-23 20:58:30 +00:00
|
|
|
class Neuron
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
double outputValue;
|
|
|
|
std::vector<double> outputWeights;
|
2015-10-15 20:16:34 +00:00
|
|
|
double gradient;
|
2015-03-23 20:58:30 +00:00
|
|
|
|
|
|
|
public:
|
2015-03-24 12:45:38 +00:00
|
|
|
Neuron(double value = 1.0);
|
|
|
|
|
2015-03-23 20:58:30 +00:00
|
|
|
void setOutputValue(double value);
|
|
|
|
void feedForward(double inputValue);
|
2015-10-26 06:33:45 +00:00
|
|
|
double getWeightedOutputValue(size_t outputNeuron) const;
|
2015-10-22 14:02:27 +00:00
|
|
|
|
2015-10-15 20:37:13 +00:00
|
|
|
void createRandomOutputWeights(size_t numberOfWeights);
|
2015-10-22 14:02:27 +00:00
|
|
|
void createOutputWeights(std::list<double> weights);
|
|
|
|
void createOutputWeights(size_t numberOfWeights, double weight);
|
|
|
|
|
2015-03-23 20:58:30 +00:00
|
|
|
double getOutputValue() const;
|
2015-10-15 20:16:34 +00:00
|
|
|
|
|
|
|
void calcOutputGradients(double targetValue);
|
2015-10-16 20:59:04 +00:00
|
|
|
void calcHiddenGradients(const Layer &nextLayer);
|
|
|
|
|
2015-10-16 21:23:27 +00:00
|
|
|
double getGradient() const;
|
|
|
|
|
2015-10-17 20:05:27 +00:00
|
|
|
double getOutputWeight(size_t index) const;
|
|
|
|
void setOutputWeight(size_t index, double value);
|
2015-10-25 16:40:22 +00:00
|
|
|
size_t getNumOutputWeights() const;
|
2015-10-17 20:05:27 +00:00
|
|
|
|
2015-10-16 20:59:04 +00:00
|
|
|
private:
|
|
|
|
static double transferFunction(double inputValue);
|
|
|
|
static double transferFunctionDerivative(double inputValue);
|
|
|
|
double sumDOW(const Layer &nextLayer) const;
|
|
|
|
|
2015-03-23 20:58:30 +00:00
|
|
|
};
|