From 411f66a2540fa17c736116d865e0ceb0cfe5623b Mon Sep 17 00:00:00 2001 From: jeanne Date: Wed, 11 May 2022 09:54:38 -0700 Subject: Initial commit. --- src/lib/test/test_util.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/lib/test/test_util.h (limited to 'src/lib/test/test_util.h') 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 @@ +#pragma once + +#include + +#include + +// General epsilon for comparing values. +static const R EPS = 1e-10; + +// Epsilon for comparing network weights after training. +static const R WEIGHT_EPS = 0.01; + +// Epsilon for comparing network outputs after training. +static const R OUTPUT_EPS = 0.01; + +static inline bool double_eq(double a, double b, double eps) { + return fabs(a - b) <= eps; +} + +static inline R lerp(R a, R b, R t) { + return a + t*(b-a); +} -- cgit v1.2.3