I am not sure if I understand correctly what is nnue.
Does it means that it is some black box that humans cannot understand what is in it.
I even do not know where to find the evaluation of stockfish to see if I can understand something and I asked in a different thread where to find it(do not plan to spend a lot of time to search it by looking at different files).
I basically remember from reading claims that every engine can improve the evaluation function it has by NNUE combined with the original evaluation and optimizing it based on search
but I do not understand what is the new evaluation function.
I read the following about stockfish that basically I understand nothing from it:
"The neural network of Stockfish NNUE consists of four layers, W1 through W4. The input layer W1 is heavily overparametrized, feeding in the board representation for various king configurations. The efficiency of the net is due to incremental update of W1 in make and unmake move, where only a fraction of its neurons need to be recalculated. The remaining three layers with 32x2x256, 32x32 and 32x1 weights are computational less expensive, best calculated using appropriate SIMD instructions like AVX2 on x86-64, or if available, AVX-512."
Is there a step by step instruction how to calculate evaluation of one position with nnue for humans?
Stockfish with nnue is not an extremely slow searcher so I think that it should be possible for humans to follow all the calculation even if it takes many hours for a human to calculate one position.
nnue evaluation question
Moderators: hgm, Rebel, chrisw
-
- Posts: 10427
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
-
- Posts: 12617
- Joined: Wed Mar 08, 2006 8:57 pm
- Location: Redmond, WA USA
Re: nnue evaluation question
https://www.researchgate.net/figure/How ... _308094289
You won't find explanations of exactly what the layers are doing as far as chess decisions.
They teach themselves based on the inputs and write the data to a file, but to us it is opaque.
You won't find explanations of exactly what the layers are doing as far as chess decisions.
They teach themselves based on the inputs and write the data to a file, but to us it is opaque.
Taking ideas is not a vice, it is a virtue. We have another word for this. It is called learning.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
But sharing ideas is an even greater virtue. We have another word for this. It is called teaching.
-
- Posts: 2832
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
Re: nnue evaluation question
Hmm, you try to read a neural network like a multidimensional PSQT? It is not that simple, as mentioned, NNs are pretty much a black-box*
Re: How to get started with NNUE
viewtopic.php?p=957108#p957108
* Understanding AlphaZero Neural Network’s SuperHuman Chess Ability
https://www.marktechpost.com/2021/12/16 ... s-ability/
--
Srdja
Re: How to get started with NNUE
viewtopic.php?p=957108#p957108
* Understanding AlphaZero Neural Network’s SuperHuman Chess Ability
https://www.marktechpost.com/2021/12/16 ... s-ability/
--
Srdja
Last edited by smatovic on Mon Mar 25, 2024 5:25 pm, edited 2 times in total.
-
- Posts: 10427
- Joined: Thu Mar 09, 2006 12:37 am
- Location: Tel-Aviv Israel
Re: nnue evaluation question
I think that at least it should be possible to have a discription of the mathematical computations that stockfish does to evaluate a single position even if humans do not understand how it is connected to chess.Dann Corbit wrote: ↑Mon Mar 25, 2024 5:12 pm https://www.researchgate.net/figure/How ... _308094289
You won't find explanations of exactly what the layers are doing as far as chess decisions.
They teach themselves based on the inputs and write the data to a file, but to us it is opaque.
How many calculation does it do in order to evaluate a single position?
-
- Posts: 27945
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: nnue evaluation question
Each link in the NN requires a multiplication and an addition, and the sum S of those for the 'neuron' they lead to requires the calculation of max(0, S). (At least, I though the units of the Stockfish NN are ReLu?)
So basically you have 256 sets of PST for each King location, and to update the 'material evaluation' for a set requires subtraction of the PST value for the moved piece in its old location, and addition of it in the new location. The 256 thus updated material evaluations are fully connected to the next layer of 32 ReLu units. So that is 32*256 additions plus multiplications. The next layer is again 32 units and fully connected, so this time 32*32 additions plus multiplications. Finally, to get the single output you need 32 more multiplications and additions.
(I could be off by a factor 2, because there are 256 PST for the location of one King, and 256 for the location of the other.)
So basically you have 256 sets of PST for each King location, and to update the 'material evaluation' for a set requires subtraction of the PST value for the moved piece in its old location, and addition of it in the new location. The 256 thus updated material evaluations are fully connected to the next layer of 32 ReLu units. So that is 32*256 additions plus multiplications. The next layer is again 32 units and fully connected, so this time 32*32 additions plus multiplications. Finally, to get the single output you need 32 more multiplications and additions.
(I could be off by a factor 2, because there are 256 PST for the location of one King, and 256 for the location of the other.)
-
- Posts: 234
- Joined: Thu Jul 21, 2022 12:30 am
- Full name: Chesskobra
Re: nnue evaluation question
You could start with https://github.com/asdfjkl/neural_network_chess (which I have browsed through, not read in detail). I think it is a very good reference, which also shows code to implement NN for some simple games yourself.
-
- Posts: 2832
- Joined: Wed Mar 10, 2010 10:18 pm
- Location: Hamburg, Germany
- Full name: Srdja Matovic
Re: nnue evaluation question
...I guess the non-linear activation function prevents humans from "reading" neural networks weights/layers, or alike.
https://en.wikipedia.org/wiki/Activation_function
https://en.wikipedia.org/wiki/Rectifier ... _networks)
https://en.wikipedia.org/wiki/Softmax_function
--
Srdja
https://en.wikipedia.org/wiki/Activation_function
https://en.wikipedia.org/wiki/Rectifier ... _networks)
https://en.wikipedia.org/wiki/Softmax_function
--
Srdja
-
- Posts: 27945
- Joined: Fri Mar 10, 2006 10:06 am
- Location: Amsterdam
- Full name: H G Muller
Re: nnue evaluation question
If the activation function was linear, the whole network could be collapsed to a single layer. The output would just be the weighted sum of all inputs.
So basically we cannot understand what it does, because it actually does something.![Laughing :lol:](./images/smilies/icon_lol.gif)
So basically we cannot understand what it does, because it actually does something.
![Laughing :lol:](./images/smilies/icon_lol.gif)
-
- Posts: 1582
- Joined: Thu Jul 16, 2009 10:47 am
- Location: Almere, The Netherlands
Re: nnue evaluation question
It is beyond human understanding, perhaps aliens comprehend what it actually does.
-
- Posts: 7226
- Joined: Mon May 27, 2013 10:31 am
Re: nnue evaluation question
Black boxes (that is AI) taking over the world. The chances of anything coming from .. are a million to one.