added Perceptron network
This commit is contained in:
20
include/NeuralNetwork/FeedForward/Perceptron.h
Normal file
20
include/NeuralNetwork/FeedForward/Perceptron.h
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "./Network.h"
|
||||||
|
#include <NeuralNetwork/ActivationFunction/Heaviside.h>
|
||||||
|
|
||||||
|
namespace NeuralNetwork {
|
||||||
|
namespace FeedForward {
|
||||||
|
class Perceptron : private Network{
|
||||||
|
public:
|
||||||
|
inline Perceptron(size_t _inputSize,size_t _outputSize):Network(_inputSize) {
|
||||||
|
appendLayer(_outputSize,ActivationFunction::Heaviside(0.0));
|
||||||
|
};
|
||||||
|
|
||||||
|
using Network::computeOutput;
|
||||||
|
using Network::randomizeWeights;
|
||||||
|
using Network::operator[];
|
||||||
|
protected:
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
38
include/NeuralNetwork/Learning/PerceptronLearning.h
Normal file
38
include/NeuralNetwork/Learning/PerceptronLearning.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
#include <NeuralNetwork/FeedForward/Network.h>
|
||||||
|
#include "CorrectionFunction/Linear.h"
|
||||||
|
|
||||||
|
namespace NeuralNetwork {
|
||||||
|
namespace Learning {
|
||||||
|
|
||||||
|
/** @class BackPropagation
|
||||||
|
* @brief
|
||||||
|
*/
|
||||||
|
class PerceptronLearning {
|
||||||
|
|
||||||
|
public:
|
||||||
|
inline PerceptronLearning(FeedForward::Network &feedForwardNetwork): network(feedForwardNetwork), learningCoefficient(0.4) {
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~PerceptronLearning() {
|
||||||
|
}
|
||||||
|
|
||||||
|
PerceptronLearning(const PerceptronLearning&)=delete;
|
||||||
|
PerceptronLearning& operator=(const NeuralNetwork::Learning::PerceptronLearning&) = delete;
|
||||||
|
|
||||||
|
void teach(const std::vector<float> &input, const std::vector<float> &output);
|
||||||
|
|
||||||
|
inline virtual void setLearningCoefficient (const float& coefficient) { learningCoefficient=coefficient; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
FeedForward::Network &network;
|
||||||
|
|
||||||
|
float learningCoefficient;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user