backprop: momentums + decay, quickprop: renaming
This commit is contained in:
@@ -31,6 +31,22 @@ namespace Learning {
|
||||
|
||||
inline virtual void setLearningCoefficient (const float& coefficient) { learningCoefficient=coefficient; }
|
||||
|
||||
float getMomentumWeight() const {
|
||||
return momentumWeight;
|
||||
}
|
||||
|
||||
void setMomentumWeight(const float& m) {
|
||||
momentumWeight=m;
|
||||
}
|
||||
|
||||
float getWeightDecay() const {
|
||||
return weightDecay;
|
||||
}
|
||||
|
||||
void setWeightDecay(const float& wd) {
|
||||
weightDecay=wd;
|
||||
}
|
||||
|
||||
protected:
|
||||
|
||||
virtual inline void resize() {
|
||||
@@ -41,11 +57,25 @@ namespace Learning {
|
||||
if(slopes[i].size()!=network[i].size())
|
||||
slopes[i].resize(network[i].size());
|
||||
}
|
||||
|
||||
if(lastDeltas.size()!=network.size())
|
||||
lastDeltas.resize(network.size());
|
||||
|
||||
for(std::size_t i=0; i < network.size(); i++) {
|
||||
if(lastDeltas[i].size()!=network[i].size()) {
|
||||
lastDeltas[i].resize(network[i].size());
|
||||
|
||||
for(std::size_t j = 0; j < lastDeltas[i].size(); j++) {
|
||||
lastDeltas[i][j] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
deltas= lastDeltas;
|
||||
}
|
||||
|
||||
virtual void updateWeights(const std::vector<float> &input);
|
||||
|
||||
virtual void computeDeltas(const std::vector<float> &expectation);
|
||||
virtual void computeSlopes(const std::vector<float> &expectation);
|
||||
|
||||
FeedForward::Network &network;
|
||||
|
||||
@@ -53,7 +83,13 @@ namespace Learning {
|
||||
|
||||
float learningCoefficient;
|
||||
|
||||
float momentumWeight = 0.0;
|
||||
|
||||
float weightDecay = 0.0;
|
||||
|
||||
std::vector<std::vector<float>> slopes;
|
||||
std::vector<std::vector<float>> deltas;
|
||||
std::vector<std::vector<float>> lastDeltas;
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user