- Blind mode tutorial
lichess.org
Donate

I am developping a neural-network based Chess engine

I don't understand why moves have to be represented as separate neurons. A position is a position, legal moves follow from the placement of pieces ( apart from turn the only distinction I can think of is ep. capture ).

Also it seems that the go to language for machine learning is Python. I did my experiment in Javascript to be able to run in the browser and add GUI to it ( may be share it on the Web ), but this was just an excercise.

I'm currently looking at TensorFlow:

https://www.tensorflow.org/get_started/get_started

"TensorFlow was originally developed by researchers and engineers working on the Google Brain Team within Google's Machine Intelligence research organization for the purposes of conducting machine learning and deep neural networks research, but the system is general enough to be applicable in a wide variety of other domains as well."

I was able to install TensorFlow and actually could run some basic getting started examples ( used Miniconda package manager for installation, much more powerful than pip ).

I read that TensorFlow BY DEFAULT uses multiple cores. You only have to worry about the model and performance is taken care of for you.

Also TensorFlow has high level abstractions, so training the model is a built in functionality, you can forget about trying to write backpropagation code by hand.

I don't understand why moves have to be represented as separate neurons. A position is a position, legal moves follow from the placement of pieces ( apart from turn the only distinction I can think of is ep. capture ). Also it seems that the go to language for machine learning is Python. I did my experiment in Javascript to be able to run in the browser and add GUI to it ( may be share it on the Web ), but this was just an excercise. I'm currently looking at TensorFlow: https://www.tensorflow.org/get_started/get_started "TensorFlow was originally developed by researchers and engineers working on the Google Brain Team within Google's Machine Intelligence research organization for the purposes of conducting machine learning and deep neural networks research, but the system is general enough to be applicable in a wide variety of other domains as well." I was able to install TensorFlow and actually could run some basic getting started examples ( used Miniconda package manager for installation, much more powerful than pip ). I read that TensorFlow BY DEFAULT uses multiple cores. You only have to worry about the model and performance is taken care of for you. Also TensorFlow has high level abstractions, so training the model is a built in functionality, you can forget about trying to write backpropagation code by hand.

Annuntio vobis gaudium magnum: habemus neural enginem!

I broke through with TensorFlow and now I have a trainable neural chess engine with persistence.

Architecture: the input is bitboards for all pieces ( 768 input neurons ), two hidden layers of 768 sigmoid neurons and a single output neuron which outputs the evaluation.

The network is trained with gradient descent ( built in function in TensorFlow, one line of code needed ). Persistence is provided by saving the weights to a TensorFlow checkpoint.

The engine can only play black and does not know the en passant rule. The network is taught Stockfish evaluations reached after half a second of thinking.

I'm really thrilled now where this is going, only after a few games the engine realized that it is good to push center pawns.

Of course the engine is terribly weak and gets mated in 10-15 moves.

I emphasize that I have no hope that this engine could play meaningful chess. I would be satisfied if it could overperform random moves by a clear margin.

It was really a headache to get something going in TensorFlow because it requires a different kind of thinking. You define nodes, which look like assignments, but they don't do anything if you don't run them in a session. There are all kind of problems with variable names, the state of the graph and the like.

Nevertheless here is the core TensorFlow code that finally worked:

https://gist.github.com/anonymous/133d8353ba817a721e67694bad922226

Annuntio vobis gaudium magnum: habemus neural enginem! I broke through with TensorFlow and now I have a trainable neural chess engine with persistence. Architecture: the input is bitboards for all pieces ( 768 input neurons ), two hidden layers of 768 sigmoid neurons and a single output neuron which outputs the evaluation. The network is trained with gradient descent ( built in function in TensorFlow, one line of code needed ). Persistence is provided by saving the weights to a TensorFlow checkpoint. The engine can only play black and does not know the en passant rule. The network is taught Stockfish evaluations reached after half a second of thinking. I'm really thrilled now where this is going, only after a few games the engine realized that it is good to push center pawns. Of course the engine is terribly weak and gets mated in 10-15 moves. I emphasize that I have no hope that this engine could play meaningful chess. I would be satisfied if it could overperform random moves by a clear margin. It was really a headache to get something going in TensorFlow because it requires a different kind of thinking. You define nodes, which look like assignments, but they don't do anything if you don't run them in a session. There are all kind of problems with variable names, the state of the graph and the like. Nevertheless here is the core TensorFlow code that finally worked: https://gist.github.com/anonymous/133d8353ba817a721e67694bad922226

You do not present moves at neurons.

Basically there is presentation of the board
that is fed to neural net and on its output you get Pwin. You choose move by having a program that feed the positions i.e from starting position all possible moves.

Based on these probabilities you do MCTS and using top -n moves from neural net to direct the search.

And the neural net is DCNN type and load of layers.

FOr NN use the googles tensor flow. Writing your own would be silly

And before starting read the:

  • paper on alpha go
  • paper on Alpha Go Zero
  • Paper on Alpha Zero
  • Some pretty good book about deep learnign in the 1st place
    Then see the LeelaZero project that is duplicating the AlphaGoZero project. And do the traingin it has to be community effort. So they have loads of code that can be used to share the training amongst paritcipants.

And there plenty of code to write. But before the 1st line of code you really need to work out the board presentation and and NN architecture you are gonna use

You do not present moves at neurons. Basically there is presentation of the board that is fed to neural net and on its output you get Pwin. You choose move by having a program that feed the positions i.e from starting position all possible moves. Based on these probabilities you do MCTS and using top -n moves from neural net to direct the search. And the neural net is DCNN type and load of layers. FOr NN use the googles tensor flow. Writing your own would be silly And before starting read the: - paper on alpha go - paper on Alpha Go Zero - Paper on Alpha Zero - Some pretty good book about deep learnign in the 1st place Then see the LeelaZero project that is duplicating the AlphaGoZero project. And do the traingin it has to be community effort. So they have loads of code that can be used to share the training amongst paritcipants. And there plenty of code to write. But before the 1st line of code you really need to work out the board presentation and and NN architecture you are gonna use

Instead of re-inventing the wheel, why not continue the Giraffe project? Github has all you need to get the code, and start training it. It's already at IM strength for now, you could bring it up to Alpha Zero Strength by training it against the latest versions of Stockfish, and it's suped up clones, then turn it loose. It was Matthew Lai's first baby before Alpha Go / Zero. It's all open source.

Instead of re-inventing the wheel, why not continue the Giraffe project? Github has all you need to get the code, and start training it. It's already at IM strength for now, you could bring it up to Alpha Zero Strength by training it against the latest versions of Stockfish, and it's suped up clones, then turn it loose. It was Matthew Lai's first baby before Alpha Go / Zero. It's all open source.

I think a gradual approach is helpful when getting acquinted with neural networks. I started off with this book:

http://neuralnetworksanddeeplearning.com/chap1.html

In this book there is a good introduction to basic concepts and it contains an easy to follow and heavily commented elementary Python implementation which does not use any machine learning library ( only NumPy for matrix operations ). I implemented this code in Javascript and ran it in the browser with graphical representation of the network so that I can see what is going on and get a feel for it.

Then I turned to TensorFlow, where the backpropagation / gradient descent is done by the library and also it is faster because the actual calculation runs outside Python.

I think it is good to go through this from the bottom up, because if your first step is to try to understand a complicated program, it would give you the wrong idea and you would get lost in the forest.

Now that I have some basic understanding, may be I'm better equipped to turn to some already existing programs and try to understand how they work.

I think a gradual approach is helpful when getting acquinted with neural networks. I started off with this book: http://neuralnetworksanddeeplearning.com/chap1.html In this book there is a good introduction to basic concepts and it contains an easy to follow and heavily commented elementary Python implementation which does not use any machine learning library ( only NumPy for matrix operations ). I implemented this code in Javascript and ran it in the browser with graphical representation of the network so that I can see what is going on and get a feel for it. Then I turned to TensorFlow, where the backpropagation / gradient descent is done by the library and also it is faster because the actual calculation runs outside Python. I think it is good to go through this from the bottom up, because if your first step is to try to understand a complicated program, it would give you the wrong idea and you would get lost in the forest. Now that I have some basic understanding, may be I'm better equipped to turn to some already existing programs and try to understand how they work.

#25
if you start training on something that has trained a lot on some known engine it is quite unlikely that it will ever reach same strength as NN that is trained by pire selfplay. Error plane is probably not convex and contains local minima and prior learning will make a bette stockfish clone . Not a another A0

#25 if you start training on something that has trained a lot on some known engine it is quite unlikely that it will ever reach same strength as NN that is trained by pire selfplay. Error plane is probably not convex and contains local minima and prior learning will make a bette stockfish clone . Not a another A0

Giraffe is open source why not play around with that ?

Giraffe is open source why not play around with that ?

Giraffe as it stands hasn't been trained against Stockfish. If you see on github it is exactly what Alpha Zero was. It was given the rules of chess, and some human examples, and it self played itself for 72 hours, and became IM Strength.

Giraffe as it stands hasn't been trained against Stockfish. If you see on github it is exactly what Alpha Zero was. It was given the rules of chess, and some human examples, and it self played itself for 72 hours, and became IM Strength.

This topic has been archived and can no longer be replied to.