quickProapagtion and tests
This commit is contained in:
@@ -33,7 +33,7 @@ namespace Learning {
|
||||
|
||||
protected:
|
||||
|
||||
inline void resize() {
|
||||
virtual inline void resize() {
|
||||
if(deltas.size()!=network.size())
|
||||
deltas.resize(network.size());
|
||||
|
||||
@@ -43,6 +43,8 @@ namespace Learning {
|
||||
}
|
||||
}
|
||||
|
||||
virtual void updateWeights(const std::vector<float> &input);
|
||||
|
||||
FeedForward::Network &network;
|
||||
|
||||
CorrectionFunction::CorrectionFunction *correctionFunction;
|
||||
|
||||
55
include/NeuralNetwork/Learning/QuickPropagation.h
Normal file
55
include/NeuralNetwork/Learning/QuickPropagation.h
Normal file
@@ -0,0 +1,55 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <cmath>
|
||||
|
||||
#include <NeuralNetwork/FeedForward/Network.h>
|
||||
#include "BackPropagation.h"
|
||||
|
||||
namespace NeuralNetwork {
|
||||
namespace Learning {
|
||||
|
||||
/** @class QuickPropagation
|
||||
* @brief
|
||||
*/
|
||||
class QuickPropagation : public BackPropagation {
|
||||
|
||||
public:
|
||||
inline QuickPropagation(FeedForward::Network &feedForwardNetwork, CorrectionFunction::CorrectionFunction *correction = new CorrectionFunction::Linear()):
|
||||
BackPropagation(feedForwardNetwork,correction),deltasPrev() {
|
||||
resize();
|
||||
}
|
||||
|
||||
virtual ~QuickPropagation() {
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual inline void resize() override {
|
||||
if(deltas.size()!=network.size())
|
||||
deltas.resize(network.size());
|
||||
|
||||
for(std::size_t i=0; i < network.size(); i++) {
|
||||
if(deltas[i].size()!=network[i].size())
|
||||
deltas[i].resize(network[i].size());
|
||||
}
|
||||
|
||||
if(deltasPrev.size()!=network.size())
|
||||
deltasPrev.resize(network.size());
|
||||
|
||||
for(std::size_t i=0; i < network.size(); i++) {
|
||||
if(deltasPrev[i].size()!=network[i].size())
|
||||
deltasPrev[i].resize(network[i].size());
|
||||
|
||||
for(std::size_t j=0; j < deltasPrev[i].size(); j++) {
|
||||
deltasPrev[i][j]=1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual void updateWeights(const std::vector<float> &input) override;
|
||||
|
||||
std::vector<std::vector<float>> deltasPrev;
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user