From 0983031d914d5fc391805bdb1034429c2be07383 Mon Sep 17 00:00:00 2001 From: tslil Date: Sat, 16 Jan 2021 01:11:22 -0500 Subject: Quick sketch of non-determinism --- include/ct1986.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'include/ct1986.c') diff --git a/include/ct1986.c b/include/ct1986.c index c80e32a..a3b089e 100644 --- a/include/ct1986.c +++ b/include/ct1986.c @@ -16,6 +16,12 @@ static float flattened[CONV_NUM+2]; static float dense1[DENSE1_NUM]; static float dense2[DENSE2_NUM]; +#ifndef DETERMINISTIC +static uint32_t x = 1; +#define DOXORSHIFT { x ^= x << 13; x ^= x >> 17; x ^= x << 5; } +#define FUDGE (((float)(x&255))/255.0-0.5)*0.2 +#endif + #define RELU(x) ((x) = ((x)<0)?0:(x)) float @@ -91,9 +97,12 @@ ct1986_evaluate_black_win(void) { for (uint8_t d2 = 0; d2 < DENSE2_NUM; d2++) { output += dense2[d2]*output_weights[d2]; } - // Truncated Pade approximant of logistic function output = (12.0+output+50.0*output/(output*output+10.0))/24.0; +#ifndef DETERMINISTIC + DOXORSHIFT; + output += FUDGE; +#endif if (output > 1.0) return 1.0; else if (output < 0.0) return 0.0; -- cgit v1.3.1