diff --git a/src/neuron.hxx b/src/neuron.hxx
index 7ccaec0..931d230 100644
--- a/src/neuron.hxx
+++ b/src/neuron.hxx
@@ -167,6 +167,7 @@
@page biblio Bibliography
- Artificial Neural Networks: Matrix Form (Part 5)
+ - Artificial Neural Networks: Mathematics of Backpropagation (Part 4)
- Vorlesung Neuronale Netze - Zusammenfassung - Christoph Tornau
- Neuronale Netze — Eine Einführung
- Artificial Neural Network based Curve Prediction
@@ -179,11 +180,11 @@
namespace math {
// tangens hyperbolicus as standard activation function
template TYPE tanh(const TYPE& v) {
- return ::tanh((double)v);
+ return ::tanh((long double)v);
}
// derivate of activation function for back propagation
template TYPE tanh_diff(const TYPE& v) {
- TYPE ch(::cosh((double)v));
+ TYPE ch(::cosh((long double)v));
return 1/(ch*ch);
}
}
@@ -200,13 +201,19 @@ class NeuroNet {
public:
NeuroNet() {
}
- Matrix feed(Matrix in) {
+ Matrix operator()(const Matrix& in) {
Matrix l((in*_wi).apply(ACTIVATION));
for (int i(0); i out((l*_wo).apply(ACTIVATION));
return out;
}
+ Matrix learn(const Matrix& in,
+ const Matrix& expect) {
+ Matrix out((*this)(in));
+ Matrix diff(expect-out);
+ return diff;
+ }
private:
Matrix _wi;
Matrix _wh[HIDDEN_LAYERS-1];
diff --git a/test/neuron.cxx b/test/neuron.cxx
index 7ea2a9b..8a42bc5 100644
--- a/test/neuron.cxx
+++ b/test/neuron.cxx
@@ -31,12 +31,16 @@ class NeuroNetTest: public CppUnit::TestFixture {
1,
1,
-1};
+ for (int step(0); step<10; ++step)
+ for (int i(0); i