julien2313
julien2313

Reputation: 339

Train feedforward neural network

I have a feedforward neural network, his goal is to learn how to play to a game (in exemple, the connect 4). I would like to train my neural network by playing games against itself.

My problem is, I don't know how to train my neural network. If I had another good algorithm which determines the best move for a given board, it would be, in my mind, easier, but I don't want to use this way.

So, I don't know if a move is a good move or not, I only know which player won (the neural network play both player, but I know if it's the first or the second player who won), and the moves played during the game.

At the moment, I wrote a program in Go which initialize a neural network, can check if a board of connect 4 is win or not, calcul the output of the neural network according to the board and you can play against the neural network, or let it play against itself. For me, I just need of a function which train my neural network at the end of a game ? There is what I did : https://github.com/Julien2313/connectFour

Upvotes: 0

Views: 402

Answers (1)

Andnp
Andnp

Reputation: 674

To use a neural network (or in fact any supervised learning method) for autonomous game playing, you need to determine a numerical or categorical value that the algorithm can learn.

One potential solution would be to map game state to actions. Another would be to map game state to score. But in some games these may not be possible to learn (Connect 4 has no score), or data may not be readily available. In this situation supervised learning algorithms cannot (or at least should not) be used.

Another framework for machine learning exists called Reinforcement Learning that handles this problem quite elegantly. Instead of providing a neural network with labelled data, you can train an algorithm to pick moves (or actions) throughout the game providing only a 1 if the algorithm (agent) won and a -1 if the agent lost.

The most popular algorithm (although perhaps not the best) in this framework is Q-Learning. In fact, it is common to combine Q-Learning with Deep Neural Networks to play incredibly challenging games. This is roughly the same set up Google's Deepmind including David Silver used to beat Lee Sedol at Go.

I would suggest a study of Richard Sutton's Reinforcement Learning: An Introduction to learn more about this subject, however for a faster learning experience Wikipedia's Q-learning article may suffice.

Upvotes: 4

Related Questions