modified learning algorithms
This commit is contained in:
@@ -13,13 +13,14 @@ namespace Learning {
|
||||
class BackPropagation {
|
||||
|
||||
public:
|
||||
BackPropagation(): learningCoefficient(0.4) {
|
||||
|
||||
inline BackPropagation(FeedForward::Network &feedForwardNetwork): network(feedForwardNetwork), learningCoefficient(0.4), deltas() {
|
||||
resize();
|
||||
}
|
||||
|
||||
virtual ~BackPropagation() {
|
||||
}
|
||||
|
||||
void teach(FeedForward::Network &n,const std::vector<float> &input, const std::vector<float> &output);
|
||||
void teach(const std::vector<float> &input, const std::vector<float> &output);
|
||||
|
||||
inline virtual void setLearningCoefficient (const float& coefficient) { learningCoefficient=coefficient; }
|
||||
|
||||
@@ -27,7 +28,22 @@ namespace Learning {
|
||||
inline virtual float correction(const float & expected, const float &computed) const {
|
||||
return expected-computed;
|
||||
};
|
||||
|
||||
inline void resize() {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
FeedForward::Network &network;
|
||||
|
||||
float learningCoefficient;
|
||||
|
||||
std::vector<std::vector<float>> deltas;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ namespace Learning {
|
||||
class OpticalBackPropagation : public BackPropagation {
|
||||
|
||||
public:
|
||||
OpticalBackPropagation(): BackPropagation() {
|
||||
OpticalBackPropagation(FeedForward::Network &feedForwardNetwork): BackPropagation(feedForwardNetwork) {
|
||||
|
||||
}
|
||||
virtual ~OpticalBackPropagation() {
|
||||
|
||||
Reference in New Issue
Block a user