Changes

Jump to: navigation, search

ConvChess

7,482 bytes added, 13:29, 30 May 2021
Created page with "'''Home * Engines * ConvChess''' FILE:2D Convolution Animation.gif|border|right|thumb| Convolutional Layer Animation <ref>[https://commons.wikimedia.org/w..."
'''[[Main Page|Home]] * [[Engines]] * ConvChess'''

[[FILE:2D Convolution Animation.gif|border|right|thumb| Convolutional Layer Animation <ref>[https://commons.wikimedia.org/wiki/File:2D_Convolution_Animation.gif 2D Image-Kernel Convolution Animation] by Michael Plotke, January 28, 2013, [https://en.wikipedia.org/wiki/Wikimedia_Commons Wikimedia Commons]</ref> ]]

'''ConvChess''',<br/>
a didactic [[Neural Networks#Convolutional|convolutional neural network]] (CNN) chess playing entity designed and implemented by [[Barak Oshri]] and [[Nishith Khandwala]] during their 2015 project work at [[Stanford University]] <ref name="paper">[[Barak Oshri]], [[Nishith Khandwala]] ('''2015'''). ''Predicting Moves in Chess using Convolutional Neural Networks''. [http://vision.stanford.edu/teaching/cs231n/reports/2015/pdfs/ConvChess.pdf pdf]</ref>.
ConvChess was likely the first chess playing entity using a CNN, as mentioned by [[Matthia Sabatelli]] et al. <ref>[[Matthia Sabatelli]], [[Francesco Bidoia]], [[Valeriu Codreanu]], [[Marco Wiering]] ('''2018'''). ''Learning to Evaluate Chess Positions with Deep Neural Networks and Limited Lookahead''. ICPRAM 2018, [https://www.ai.rug.nl/~mwiering/GROUP/ARTICLES/ICPRAM_CHESS_DNN_2018.pdf pdf]</ref>.
ConvChess is implemented in [[Python]], using the [[python-chess]] and [https://en.wikipedia.org/wiki/NumPy NumPy] libraries, source code and datasets available on [https://en.wikipedia.org/wiki/GitHub GitHub] <ref>[https://github.com/BarakOshri/ConvChess GitHub - BarakOshri/ConvChess: Predicting Moves in Chess Using Convolutional Neural Networks]</ref>.

=Idea=
Inspired by the [[Supervised Learning|supervised learning]] approach of [[Christopher Clark]] and [[Amos Storkey]] to predict moves in [[Go]] without any [[Search|search]],
to defeat the traditional search program [[Gnu Go]] in 86% of the games <ref>[[Christopher Clark]], [[Amos Storkey]] ('''2014'''). ''Teaching Deep Convolutional Neural Networks to Play Go''. [http://arxiv.org/abs/1412.3409 arXiv:1412.3409]</ref>,
Oshri and Khandwala tried a similar idea to implement a move predictor or policy network in Chess. They were well aware that such winning rates without search as reported in Go are not possible in Chess, first due to the tactical nature of the game,
and also due to move classification aspect that [[Moves|chess moves]] require [[Origin Square|origin square]] and [[Target Square|target square]], instead of a single coordinate for a 19x19 grid to drop a stone.
Therefore in this novel approach, the classification was divided into two parts. The first part trains a piece-selector CNN to predict the origin square a piece moves from,
while the second part trains six move-selector CNNs to encode which target squares would be advantageous for each of the six possible [[Pieces#PieceTypeCoding|piece types]].
These seven CNNs take the [[Board Representation|board representation]] as input and output a probability distribution for 64 origin and 6x64 target squares.
The predicted move is then obtained by composing the piece-selector CNN by multiplying its values by the highest value in the corresponding move-selector CNN,
clipping all illegal origins and targets to zero, and taking the [https://en.wikipedia.org/wiki/Arg_max arg max] over the entire composition.
Since the model considers White to move only, Black to move positions require a [[Color Flipping|color flip]].

=Network=
Each of the seven CNNs consists of three [https://en.wikipedia.org/wiki/Convolutional_neural_network#Convolutional_layer convolutional layers] with 32 3x3 filters stride 1, including [https://en.wikipedia.org/wiki/Rectifier_(neural_networks) ReLU] and 2x2 [https://en.wikipedia.org/wiki/Convolutional_neural_network#Pooling_layer pooling layer] stride 2 (The authors reported less success using five convolution layers <ref>[http://www.talkchess.com/forum3/viewtopic.php?t=63458&start=1 Re: ConvChess CNN] by [[Álvaro Begué]], [[CCC]], March 15, 2017</ref>)
followed by two [https://en.wikipedia.org/wiki/Layer_(deep_learning)#Dense_layer fully connected layers] with a [https://en.wikipedia.org/wiki/Affine_transformation affine transformation]to 128 features, the first including ReLU and [https://en.wikipedia.org/wiki/Dilution_(neural_networks) Dropout], the second [https://en.wikipedia.org/wiki/Softmax_function Softmax].
The input layer, feeding in the [[Board Representation|board representation]] ignoring [[En passant|en passant]] square and [[Castling Rights|castling rights]], has a shape of six channels for each piece type with three possible values for each of the 8x8 squares, -1 for Black pieces, 0 for empty square, and +1 for White pieces.
The output, reflecting the number of classifications, is a vector of 64 [[Float|floats]].

=Training=
The networks were trained for 245,000 moves over 20,000 games <ref>[https://raw.githubusercontent.com/BarakOshri/ConvChess/master/data/FICS_2000.pgn ConvChess/master/data/FICS_2000.pgn]</ref>,
with the piece-selector CNN trained on every piece and each move-selector CNN trained on every move made by the respective piece, without considering the outcome of the game.
Their best model was found by doing a [https://en.wikipedia.org/wiki/Hyperparameter_optimization#Grid_search grid-search] over the parameters of [https://en.wikipedia.org/wiki/Learning_rate learning rate], [https://en.wikipedia.org/wiki/Regularization_(mathematics) regularization], and weight initialization with fine tuning afterwards.
The parameters of the best model were a regularization of 0.0001, learning rate of 0.0015, [https://en.wikipedia.org/wiki/Batch_normalization batch size] of 250, a [https://en.wikipedia.org/wiki/Learning_rate#Learning_rate_schedule learning rate decay] of 0.999 on [https://en.wikipedia.org/wiki/Stochastic_gradient_descent#RMSProp RMSprop] with no [https://en.wikipedia.org/wiki/Dilution_(neural_networks) dropout] trained in 15 [https://en.wikipedia.org/wiki/Epoch_(disambiguation)#Science_and_technology epochs] <ref name="paper"/>.

=Results=
The best result obtained with the piece-selector CNN was 38.30%. The results for the move-selector varied. Pieces with local movements (P=52%, N=56%, K=47%) performed significantly better than [[Sliding Pieces|sliding pieces]] (B=40%, R=30%, Q=27%) - the latter with more options to fail, and possibly also due to the restricted influence of only three 3x3 convolutions.
ConvChess was played against [[Sunfish]] (search depth not reported) in 100 games. 26 of the games drew and the rest were lost <ref name="paper"/>.

=Publications=
* [[Barak Oshri]], [[Nishith Khandwala]] ('''2015'''). ''Predicting Moves in Chess using Convolutional Neural Networks''. [http://vision.stanford.edu/teaching/cs231n/reports/2015/pdfs/ConvChess.pdf pdf]

=Forum Posts=
* [http://www.talkchess.com/forum3/viewtopic.php?t=63458 ConvChess CNN] by [[Brian Richardson]], [[CCC]], March 15, 2017
: [http://www.talkchess.com/forum3/viewtopic.php?t=63458&start=1 Re: ConvChess CNN] by [[Álvaro Begué]], [[CCC]], March 15, 2017

=External Links=
* [https://github.com/BarakOshri/ConvChess GitHub - BarakOshri/ConvChess: Predicting Moves in Chess Using Convolutional Neural Networks]
* [https://en.wikipedia.org/wiki/Convolutional_neural_network Convolutional neural network from Wikipedia]

=References=
<references />
'''[[Engines|Up one Level]]'''
[[Category:Open Source]]
[[Category:Python]]
[[Category:Didactic]]
[[Category:NN]]
[[Category:Chess Suffix]]

Navigation menu