Answers.Body: <p>Easy ones first:</p>
  
  <ul>
  <li>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.).</li>
  <li>You probably to structure this with <em>some</em> 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)</li>
  <li>Well worth trying some 1D convolutions (which cleverly combine channels from convolutions created by previous layers).</li>
  <li>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).</li>
  </ul>
  
  <p>Now the hard bit - encoding your input:</p>
  
  <ul>
  <li>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).</li>
  <li>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).</li>
  </ul>
  
  <p>Finally, those labels of yours: do think about what you'll do with <em>drawn</em> games - perhaps you have 3 possible outcomes, not 2?</p>
  
  <p>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!).</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-31T15:23:00.843Z
Answers.LastActivityDate: 2019-01-31T15:23:00.843Z
Answers.UserDisplayName: Edward Dixon
Answers.Body: <p>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 <a href="https://en.wikipedia.org/wiki/Reinforcement_learning" rel="nofollow noreferrer">Reinforcement Learning</a>. </p>
  
  <p>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.</p>
  
  <p>The following references might interest you:</p>
  
  <ul>
  <li><a href="https://arxiv.org/pdf/1509.01549.pdf" rel="nofollow noreferrer">Reinforcement learning for chess</a></li>
  <li><a href="https://neuro.cs.ut.ee/demystifying-deep-reinforcement-learning/" rel="nofollow noreferrer">Deep reinforcement learning</a></li>
  <li><a href="https://upcommons.upc.edu/bitstream/handle/2117/106389/119749.pdf?sequence=1&amp;isAllowed=y" rel="nofollow noreferrer">Predicting the Outcome of a Chess Game by Statistical and Machine Learning techniques</a></li>
  </ul>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-31T15:37:05.427Z
Answers.Text: 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.
Answers.UserDisplayName: Neil Slater
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-01-31T09:29:28.703Z
Answers.LastActivityDate: 2019-01-31T15:12:33.170Z
Answers.LastEditDate: 2019-01-31T15:12:33.170Z
Answers.UserDisplayName: malioboro
Body: <p>I'm trying to train a neural network on evaluating chess positions if rather white (0.0) or black would win (1.0)</p>
  
  <p>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).</p>
  
  <p>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?</p>
  
Tags: <neural-networks><machine-learning><convolutional-neural-networks>
Title: Choosing the right neural network settings
UserDisplayName: Aura Lee
ThreadText: # Choosing the right neural network settings
  
  (Asked by: username_0 on 2019-01-29)
  
  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?
  
  **Tags:** neural-networks, machine-learning, convolutional-neural-networks
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-01-31. Score: 2 | Accepted answer
  
  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!).
  
  
  ---
  
  ### Answer by username_2 on 2019-01-31. Score: 1
  
  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](https://en.wikipedia.org/wiki/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:
  
  * [Reinforcement learning for chess](https://arxiv.org/pdf/1509.01549.pdf)
  * [Deep reinforcement learning](https://neuro.cs.ut.ee/demystifying-deep-reinforcement-learning/)
  * [Predicting the Outcome of a Chess Game by Statistical and Machine Learning techniques](https://upcommons.upc.edu/bitstream/handle/2117/106389/119749.pdf?sequence=1&isAllowed=y)
  
  > **Comments:**
  > **username_3**: 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.  
  
  ---
  
  