hailiang-wang / nnetcpp

Simple, Fast and Powerful RNN for textsum
1 stars 0 forks source link

run tests failures #1

Open hailiang-wang opened 6 years ago

hailiang-wang commented 6 years ago

check out : tests assertion failtues https://github.com/steckdenis/nnetcpp/issues/2

Unit testing a neural network library is quite difficult. What I do is that I train a small neural network (based on different layers implemented in the library), and then check that its error is below a threshold. I've been quite aggressive regarding the thresholds.

I've run the tests on my computer, and they pass if run separately "tests recurrent|merge|perceptron". If I run "tests all", some tests fail (always the same ones, but a different set than yours). This is probably because the solution found by the neural network is non-deterministic and depends on the libstdc++ random number generator (for weight initialization for instance). Your RNG may be different than mine, and randomness of one test can influence the others. The library should still be completely functional.

If you use this library and have a network that cannot learn, note nnetcpp is quite sensitive to its parameters (learning rate too high (should be around 1e-4 or 1e-5), too many or too few neurons, wrong activation functions (tanh works very well)). Usually, decreasing the learning rate and giving time to the network is enough to have it learn (by "time", I mean hundreds of thousands of iterations in some cases).

hailiang-wang commented 6 years ago

To test, just run ./scripts/test.sh.

Final MSE: 0.000157573
Validation
0 0.0512579 0
1 1.09699 1
1 -0.318641 0
1 1.17821 1
0 0.967942 1
0 0.696245 1
1 0.460449 0
0 1.3176 0
Final MSE: 0.273338
test_merge.cpp:62:Assertion
Test name: TestMerge::testSum
assertion failed
- Expression: checkLearning(net, input, output, 0.001, 1000)
- Learning a linear function using MergeSum

test_recurrent.cpp:110:Assertion
Test name: TestRecurrent::testLSTM
assertion failed
- Expression: checkLearning(net, inputs[i], outputs[i], target, 1, true, true)
- A test vector failed the parity test

Failures !!!
Run: 8   Failure total: 2   Failures: 2   Errors: 0