Deep Learning Chess Engine ?
Posted: Thu Jul 21, 2016 3:21 am
Is there any deep learning chess engine which has active development ? I know giraffe but it's discontinued. If you know some of it please share. Thanks.
Hi Alexandru,brtzsnr wrote:No exactly answering your question. Zurichess uses a two layers NN where the second layer is for phasing endgame and midgame evals. I think most engines do something similar, but in Zurichess I made sure that the evaluation can be modeled as a simple NN which I train with Tensorflow (http://tensorflow.org).
I also experimented with deeper neural networks - using ReLUs for internal nodes - but I have only noticed a very small improvement in the error loss at the cost of evaluation speed which was an overall Elo regression.
I have not given up hopes, yet. Giraffe had good positional play especially in endgames where my engine is weak. I need to find the hot spot between the evaluation quality and evaluation speed.
For example, pawn structure looks something were a deeper network would be helpful. If you check "Little Chess Evaluation Compendium" you'll see that there are lots of small interdependent pawn related features for which a linear network cannot work.
Code: Select all
WM = tf.Variable(tf.random_uniform([len(x_data[0]), 1]))
WE = tf.Variable(tf.random_uniform([len(x_data[0]), 1]))
xm = tf.matmul(x_data, WM)
xe = tf.matmul(x_data, WE)
P = tf.constant(p_data)
y = xm*(1-P)+xe*P
y = tf.sigmoid(y/2)
loss = tf.reduce_mean(tf.square(y - y_data)) + 1e-4*tf.reduce_mean(tf.abs(WM) + tf.abs(WE))
optimizer = tf.train.AdamOptimizer(learning_rate=0.1)
train = optimizer.minimize(loss)
Code: Select all
else if ( abs(eg) <= BishopValueEg
&& ei.pi->pawn_span(strongSide) <= 1
&& !pos.pawn_passed(~strongSide, pos.square<KING>(~strongSide)))
sf = ei.pi->pawn_span(strongSide) ? ScaleFactor(51) : ScaleFactor(37);
Spawkfish is quite interesting. Very weak though - even Dorpsgek (~1500 Elo) beats it.thomasahle wrote:There is also Spawkfish: http://spawk.fish
Unfortunately it's not open source, but the author wrote a fee posts on how it works.
Its interesting because it doesn't try to learn evaluation, but tries to learn the correct move directly. Similar to the policy network in alphago. It also uses a quote deep network.
With no non-linearity each layer is just a matrix multiplication, and you can actually collapse all layers into one, and get an equivalent linear function. Like you said, there are many things that cannot be modeled with a linear function.brtzsnr wrote:Geneva was the first version to use tensorflow. Glarus and the current development branch improved evaluation quiet a lot using this (e.g. backward pawns, king safety, knight & bishop psqt).
The NN I use is simply:
It takes 10min for the weights to converge and I need to train it twice: once with any search disabled, and once with quiescence search enabled. Before this, I implemented a general hill-climbing algorithm, but it was converging very slow (1 day) and the results were not always very good.Code: Select all
WM = tf.Variable(tf.random_uniform([len(x_data[0]), 1])) WE = tf.Variable(tf.random_uniform([len(x_data[0]), 1])) xm = tf.matmul(x_data, WM) xe = tf.matmul(x_data, WE) P = tf.constant(p_data) y = xm*(1-P)+xe*P y = tf.sigmoid(y/2) loss = tf.reduce_mean(tf.square(y - y_data)) + 1e-4*tf.reduce_mean(tf.abs(WM) + tf.abs(WE)) optimizer = tf.train.AdamOptimizer(learning_rate=0.1) train = optimizer.minimize(loss)
Training this way is much faster than playing 100k games for SPSA, but it has the disadvantage that it somehow limits the set of usable features. The NN should compute the same value as your evaluation function - without the sigmoid. For example a linear NN won't be able to compare values as in the following code from Stockfish. Probably here you need a deeper NN.
Code: Select all
else if ( abs(eg) <= BishopValueEg && ei.pi->pawn_span(strongSide) <= 1 && !pos.pawn_passed(~strongSide, pos.square<KING>(~strongSide))) sf = ei.pi->pawn_span(strongSide) ? ScaleFactor(51) : ScaleFactor(37);