It is called NNUE , which stands for Efficiently Updatable Neural Networks (but spelled backwards
![Surprised :o](./images/smilies/icon_surprised.gif)
I would advice programmers to have a look at the talkchess.com website.
Maybe of interest for Computer Draughts.
Bert
Jonathan Kreuzer achieved pretty good results with it in 8x8 checkers, beating Cake by a small margin. It seems doable to also port this to 10x10 international draughts. I have no idea if it will beat Scan-like patterns. It does require quite some investment. The weight learning part is easy now, since Jonathan has open sourced a very clean Keras/Tensorflow script. (It should also be possible to train Scan-like patterns with it, but I haven't figured this out yet). The C++ part is quite involved, since a fast implementation does require some SIMD programming. The chess folks have optimized this using incremental updates (not yet in Jonathan's C++ code). The NNUE architecture came from the Computer Shogi community, so this is a great cross-game development.BertTuyt wrote: ↑Tue Nov 17, 2020 20:54I would invite all Draughts programmers to have a close look at http://www.3dkingdoms.com/checkers.htm.
A checkers program GuiNN Checkers 2.0 based upon a NN.
Also source code included, including NN training tools.
At least i have seen that Rein is already digging into the details.
Rein, maybe you can post/share some findings here, and your gut feel if this is the next thing for International Draughts.
Bert
Rein Halbersma wrote: ↑Wed Nov 18, 2020 11:42Jonathan Kreuzer achieved pretty good results with it in 8x8 checkers, beating Cake by a small margin. It seems doable to also port this to 10x10 international draughts. I have no idea if it will beat Scan-like patterns. It does require quite some investment. The weight learning part is easy now, since Jonathan has open sourced a very clean Keras/Tensorflow script. (It should also be possible to train Scan-like patterns with it, but I haven't figured this out yet). The C++ part is quite involved, since a fast implementation does require some SIMD programming. The chess folks have optimized this using incremental updates (not yet in Jonathan's C++ code). The NNUE architecture came from the Computer Shogi community, so this is a great cross-game development.BertTuyt wrote: ↑Tue Nov 17, 2020 20:54I would invite all Draughts programmers to have a close look at http://www.3dkingdoms.com/checkers.htm.
A checkers program GuiNN Checkers 2.0 based upon a NN.
Also source code included, including NN training tools.
At least i have seen that Rein is already digging into the details.
Rein, maybe you can post/share some findings here, and your gut feel if this is the next thing for International Draughts.
Bert
Great, porting Jonathan's code to 10x10 draughts seems relatively straightforward. Keep us posted of updates!BertTuyt wrote: ↑Mon Nov 30, 2020 11:52Rein, thanks.
In the meantime I also started experimenting with NNUE and the checkers-code.
So far I was able to implement the checkers NNUE source-code in my Engine (Damage 15.3).
I used an input vector with 191 elements (2 * 45 white/black man, 2 * 50 white/black king and side to move).
I also succeeded to generate a weights-file with the Python script and TensorFlow, based upon my large set of games.
As usual I have introduced some bugs, but expect in 1 - 2 weeks to have all working.
I've managed to train the Kingsrow evaluation function in Keras/TensorFlow. Ed is going to run an engine match to see how strong the Keras trained weights are compared to his own trained weights. I'll post a separate thread as soon as the results are in.Assume you also work under the radar screen on NNUE and TensorFlow.
No clue yet about performance.
My gutfeel is that the Scan patterns are still superior, and that the drop in Nodes/seconds will be to big.
Bert
Code: Select all
# Create the neural net model
model = keras.Sequential([
keras.layers.Dense(layerSizes[0], activation="relu"),
keras.layers.Dense(layerSizes[1], activation="relu"),
keras.layers.Dense(layerSizes[2], activation="relu"),
keras.layers.Dense(layerSizes[3], activation="sigmoid"), # use sigmoid for our 0-1 training labels
])
lr_schedule = keras.optimizers.schedules.ExponentialDecay(initial_learning_rate=.01,decay_steps=5000,decay_rate=0.96)
opt = keras.optimizers.Adam( learning_rate = lr_schedule )
#not sure what loss function should be or if should use sigmoid activation
model.compile(optimizer=opt, loss="mean_squared_error")
model.fit(positionData, positionLabels, batch_size= batchSizeParam, epochs= epochsParam )
Just as trailer to the full movie: I wrote Kingsrow's eval from scratch as a Keras model, it's not related at all to Jonathan's eval code. Ed provided me with 231 million positions, and the input was 5 material features, 8 pattern indices and 2 game phases, as well as the game result (W/L/D). Not counting the data loading and some low-level helper functions, the neural network takes less than 10 lines of Python code. More to come later this week.BertTuyt wrote: ↑Mon Nov 30, 2020 12:07Rein, interesting developments.
How many games/positions did you use, and was was the input vector in your case?
Did you use the same python script, or were some modifications needed to cope with the 10x10 set?
Was your input vector also with 191 elements, or did you use the larger vector which you also proposed in your previous post?
Bert
So to be clear: Jonathan Kreuzer's eval is indeed a NNUE, in the sense that you can do incremental updates and use SIMD programming for high speed in C++. It is however rather different than the Stockfish NNUE, in the sense that there are no piece interactions in the input layer. For Stockfish (and Shogi programs), the raw inputs already have all King-Piece combinations, not raw Piece squares.
It indeed is awesome. Similar things can be done in PyTorch, Facebook's competitor tool for Google's TensorFlow.