perceptron implementation changed + perceptronLearningAlgorithm and tests
This commit is contained in:
1 parent
4ef010b965
commit
a48298b342
7 files changed
+97
-7
No files matched your search
@@ -0,0 +1,15 @@
|
||||
#include <NeuralNetwork/Learning/PerceptronLearning.h>
|
||||
|
||||
void NeuralNetwork::Learning::PerceptronLearning::teach(const std::vector<float> &input, const std::vector<float> &output) {
|
||||
std::vector<float> computedOutput=perceptron.computeOutput(input);
|
||||
|
||||
std::size_t outputSize = output.size();
|
||||
|
||||
for(std::size_t i=0; i<outputSize; i++) {
|
||||
perceptron[i+1].weight(0)+=learningCoefficient*(output[i]-computedOutput[i])*1;
|
||||
for(std::size_t inputIndex=0; inputIndex<input.size(); inputIndex++) {
|
||||
float delta = learningCoefficient*(output[i]-computedOutput[i])*2*(input[inputIndex]-0.5);
|
||||
perceptron[i+1].weight(inputIndex+1)+=delta;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user