diff options
Diffstat (limited to 'include/nn.c')
| -rw-r--r-- | include/nn.c | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/include/nn.c b/include/nn.c index 7a42a02..9f15ec2 100644 --- a/include/nn.c +++ b/include/nn.c @@ -119,18 +119,19 @@ float eval_net(const float *board, const unsigned int n_inp, const float *w, const unsigned int n_dense, const float parity) { float dense1[FIVE_DENSE_NUM]; // FIVE_DENSE_NUM == SIX_DENSE_NUM - float z = logit_b; - - for (unsigned int d1 = 0; d1 < n_dense; d1++) { - float h = biases[d1]; - const float *wd = w + d1 * n_inp; - for (unsigned int fl = 0; fl < n_inp; fl++) - h += board[fl] * wd[fl]; - dense1[d1] = fast_silu(h); + for (unsigned int d1 = 0; d1 < n_dense; d1++) + dense1[d1] = biases[d1]; + for (unsigned int fl = 0; fl < n_inp; fl++) { + const float b = board[fl]; + const float *wrow = w + fl * n_dense; + for (unsigned int d1 = 0; d1 < n_dense; d1++) + dense1[d1] += b * wrow[d1]; } for (unsigned int d1 = 0; d1 < n_dense; d1++) + dense1[d1] = fast_silu(dense1[d1]); + float z = logit_b; + for (unsigned int d1 = 0; d1 < n_dense; d1++) z += dense1[d1] * logit_w[d1]; - return parity * fast_tanh(z); } |
