diff options
author | jeanne <jeanne@localhost.localdomain> | 2022-05-11 09:54:38 -0700 |
---|---|---|
committer | jeanne <jeanne@localhost.localdomain> | 2022-05-11 09:54:38 -0700 |
commit | 411f66a2540fa17c736116d865e0ceb0cfe5623b (patch) | |
tree | fa92c69ec627642c8452f928798ff6eccd24ddd6 /src/lib/test/test_util.h | |
parent | 7705b07456dfd4b89c272613e98eda36cc787254 (diff) |
Initial commit.
Diffstat (limited to 'src/lib/test/test_util.h')
-rw-r--r-- | src/lib/test/test_util.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/test/test_util.h b/src/lib/test/test_util.h new file mode 100644 index 0000000..8abb99a --- /dev/null +++ b/src/lib/test/test_util.h | |||
@@ -0,0 +1,22 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <neuralnet/types.h> | ||
4 | |||
5 | #include <math.h> | ||
6 | |||
7 | // General epsilon for comparing values. | ||
8 | static const R EPS = 1e-10; | ||
9 | |||
10 | // Epsilon for comparing network weights after training. | ||
11 | static const R WEIGHT_EPS = 0.01; | ||
12 | |||
13 | // Epsilon for comparing network outputs after training. | ||
14 | static const R OUTPUT_EPS = 0.01; | ||
15 | |||
16 | static inline bool double_eq(double a, double b, double eps) { | ||
17 | return fabs(a - b) <= eps; | ||
18 | } | ||
19 | |||
20 | static inline R lerp(R a, R b, R t) { | ||
21 | return a + t*(b-a); | ||
22 | } | ||