<p>What you need is Pointer Networks (<a href="https://arxiv.org/abs/1506.03134" rel="noreferrer">https://arxiv.org/abs/1506.03134</a>)</p>

<p>Here is a introduction quote from a post about it:</p>

<blockquote>
  <p>Pointer networks are a new neural architecture that learns pointers to positions in an input sequence. This is new because existing techniques need to have a fixed number of target classes, which isn't generally applicable— consider the Travelling Salesman Problem, in which the number of classes is equal to the number of inputs. An additional example would be sorting a variably sized sequence.
  - <a href="https://finbarr.ca/pointer-networks/" rel="noreferrer">https://finbarr.ca/pointer-networks/</a></p>
</blockquote>

<p>Its an attention based model.</p>

<p>Essentially a pointer network is used to predict pointers back to the input, meaning your output layer isn't actually fixed, but variable.</p>

<p>A use case where I have used them is for translating raw text into SQL queries. </p>

<ul>
<li>Input: "HOW MANY CARS WERE SOLD IN US IN 1983" </li>
<li>Output: SELECT COUNT(Car_id) FROM Car_table WHERE (Country='US' AND
Year=='1983')</li>
</ul>

<p>The issue with raw text such as this is that it will only make sense w.r.t to a specific table (in this case car table with a set of variables around car sales, similar to your different boards for board games). Meaning, that if the question cant be the only input. So the input that actually goes into the pointer network is a combination of -</p>

<p>Input - </p>

<ol>
<li>Query</li>
<li>Metadata of the table (column names)</li>
<li>Token vocabulary for all categorical columns</li>
<li>Keywords from SQL syntax (SELECT, WHERE etc..)</li>
</ol>

<p>All of these are appended together.</p>

<p>The output layer then simply points back to specific indexes of the input. It points to Country and Year (from column names in metadata), it points to US and 1983 (from tokens in vocabulary of categorical columns), it points to SELECT, WHERE etc from the SQL syntax component of the input.</p>

<p>The sequence of these indexes in the appended index is then used as the output of your computation graph, and optimized using a training dataset that exists as WIKISQL dataset.</p>

<p>Your case is quite similar, you need to pass the inputs, metadata of the game, and the stuff you need as part of your output as an appended index. Then the pointer network simply makes selections from the input (points to them).</p>
What type of neural network can handle variable input and output sizes?
<p>I'm trying to use the approach described in this paper <a href="https://arxiv.org/abs/1712.01815" rel="noreferrer">https://arxiv.org/abs/1712.01815</a> to make the algorithm learn a new game. </p>

<p>There is only one problem that does not directly fit into this approach. The game I am trying to learn has no fixed board size. So currently the input tensor has dimensions <code>m*n*11</code>, where m and n are the dimensions of the game board and can vary each time the game is played. So first of all I need a neural network able to make use of such varying input sizes.</p>

<p>The size of the output is also a function of the board size, as it has a vector with entries for every possible move on the board, and so the output vector will be bigger if the board size increases. </p>

<p>I have read about recurrent and recursive neural networks but they all seem to relate to NLP, and I'm not sure on how to translate that to my problem. </p>

<p>Any ideas on NN architectures able to handle my case would be welcome. </p>