diff options
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | include/ct1986.c | 11 |
2 files changed, 12 insertions, 2 deletions
@@ -1,6 +1,7 @@ IDIR=include TPDIR=3rd-party -CFLAGS=-O3 -Wall -Wextra -std=c99 -D_DEFAULT_SOURCE -I$(IDIR) -I$(TPDIR) +DEFINES=-DDETERMINISTIC +CFLAGS=-O3 -Wall -Wextra -std=c99 -D_DEFAULT_SOURCE $(DEFINES) -I$(IDIR) -I$(TPDIR) LIBS= SRCS=$(wildcard include/*.c) $(wildcard 3rd-party/*.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; |
