summaryrefslogtreecommitdiff
path: root/include/ct1986.c
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2021-01-16 01:11:22 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commit0983031d914d5fc391805bdb1034429c2be07383 (patch)
treecdce20a03c2d4f2743d0368b9c1576179296f4d9 /include/ct1986.c
parent87d8665b6615c5c572ac0c23d20d26b448eaf483 (diff)
Quick sketch of non-determinism
Diffstat (limited to 'include/ct1986.c')
-rw-r--r--include/ct1986.c11
1 files changed, 10 insertions, 1 deletions
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;