Say I'm looking to train a neural network to decide the winner of a tic-tac-toe game (contrived example I realize). The problem is that the number of moves in a given game isn't always the same. Therefore, my inputs will be of varying lengths. Are there any strategies for training a NN that do not involve "normalizing" my inputs so they're all the same lengths?

I've found 3 other posts (1, 2, 3) with essentially this same question, but they all boil down to normalizing the data into equal lengths. Are there any other strategies? Or are there any other techniques instead of NNs that can handle varying input sizes?

  • 1
    $\begingroup$ One possibility for dealing with arbitrary-length input is using Recurrent Neural Networks. If there is some order to the data (as there is in the moves in a game), the network will have 'context' when shown each new move. Another possibility people have explored is defining some lowest-level unit (a word, a move, etc) and passing them to a CNN in order. So a vector for move_1 is fed in with move_2. Then the resulting move_1_2 vector is fed with move_3, etc. $\endgroup$
    – jamesmf
    Nov 17, 2015 at 14:47
  • $\begingroup$ Answer below for your second question. To your first, I have less to offer.—ANNs have been used in reinforcement learning, but I'm unfamiliar with the details. $\endgroup$ Nov 17, 2015 at 14:48
  • $\begingroup$ @jamesmf I'm a bit confused. How do I "feed move1 in with move2"? I combine the vectors in some way? When I add in move3, won't the vector be larger leaving me with my original problem? Or are you talking about some type of sliding window? Or simply feeding in the moves in order, regardless of how many there are? $\endgroup$
    – wspeirs
    Nov 17, 2015 at 15:48
  • 1
    $\begingroup$ If you have vectors of size V the point is that you train a network that has input size of (2 x V) and output size (1 x V). At each time point you have 2 vectors of size V to feed to your network (one is the output from the step before, one is the next input). $\endgroup$
    – jamesmf
    Nov 17, 2015 at 16:10
  • $\begingroup$ Another option, most closely comparable to using RNNs in that it doesn't require changing the input data, is SPP-net: research.microsoft.com/en-us/um/people/kahe/eccv14sppnet $\endgroup$
    – tsiki
    Nov 17, 2015 at 17:54

1 Answer 1


To your second question, the field of machine learning you may want to look into is called reinforcement learning. Very briefly, reinforcement learning concerns problems of how an agent (player) should act (select squares) in an environment (tic-tac-toe board) given some formalized notion of reward (a 0-1 loss-win function, e.g.).

In fact, tic-tac-toe has been used as an example problem in reinforcement learning papers and texts.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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