1
$\begingroup$

I'm trying to train a neural network on evaluating chess positions if rather white (0.0) or black would win (1.0)

Currently the input consists of 4 bits per chess field (piece id 0 - 12, equals 64*4). Factors like castling are being ignored for now. Also, all training sets are random positions from popular games where it's white's turn and the desired output is the outcome of the game (0.0, 0.5, 1.0).

Are my input values the right choice? How many hidden layers / neurons for each layer should be used and what's the best learning rate? What type of NN's and which activation function would you recommend for this project?

$\endgroup$
2
$\begingroup$

Easy ones first:

  • Activations are going to be RELU all the way down, until your final softmax layer (win probability?) (because empirically, RELU does great on most problems, except when your model is an RNN, and it makes the gradient explode, or in the final layer of a regression model - numerical stability etc.).
  • You probably to structure this with some layers of convolutions with max pooling between them, then 1 or 2 fully connected layers (FC) near the end (because if you only have FC layers, you probably won't have enough data to train them)
  • Well worth trying some 1D convolutions (which cleverly combine channels from convolutions created by previous layers).
  • Learning rate: take the SGD default to begin with, then tune later. Problem dependent, I'm afraid! The returns to tuning can be large though (my kids twigged to this quite quickly when playing with a toy problem).

Now the hard bit - encoding your input:

  • Categorical encoding using a single integer per board position could cause your model some grief (it is an input that "looks like" a real number, but of course it isn't, and values that seem numerically close may represent pieces with radically different abilities (perhaps the code for King is 1 and Queen is 2 and Bishop is 3, but all those pieces have such different attributes).
  • I would strongly consider thinking of each piece/player combo as a "colour channel" - a 64 cell grid where each value is either zero or one (so, one channel for White's pawns, another for White's knights, and so on).

Finally, those labels of yours: do think about what you'll do with drawn games - perhaps you have 3 possible outcomes, not 2?

We would all be fascinated to hear how you get on - I hope you'll write your work up in some form (and that you'll come back and complain/praise our advice, as appropriate!).

$\endgroup$
1
$\begingroup$

Guessing the winner from a chess position is difficult for classification. In chess, even if you start from the same position, it can give you different result depends on the player's action. So, I recommend you to use Temporal Difference (TD) Learning, the driving concept behind Reinforcement Learning.

Some methods in Reinforcement Learning still use a neural net but not for predicting the winner. The prediction in Q-Learning, a popular Reinforcement Learning algorithm, predicts the "value" of choosing a certain action while in a certain position for a player. From those values, a player can choose the best action for the current position.

The following references might interest you:

$\endgroup$
  • 1
    $\begingroup$ Technically the V or Q values in RL playing board games is most often the prediction of the winner (+1 for "me", -1 for "you") from the position, which is the thing you claim as being difficult in the first paragraph. What RL self-play does is provide a version of that second player to generate data for the same classification problem. If you use Q learning and self-play, that is pretty much the only thing happening. If you use more advanced agents (e.g. with MCTS and a policy network) then you also predict action choices more directly. $\endgroup$ – Neil Slater Jan 31 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.