Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What type of neural network can handle variable input and output sizes?

I'm trying to use the approach described in this paper https://arxiv.org/abs/1712.01815 to make the algorithm learn a new game.

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 m*n*11, 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.

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.

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.

Any ideas on NN architectures able to handle my case would be welcome.

like image 431
Damian Szkaut Avatar asked Apr 04 '18 16:04

Damian Szkaut


People also ask

What are the 3 different types of neural networks?

Different types of Neural Networks in Deep LearningArtificial Neural Networks (ANN) Convolution Neural Networks (CNN) Recurrent Neural Networks (RNN)

What is input size in neural network?

In Keras, the input dimension needs to be given excluding the batch-size (number of samples). In this neural network, the input shape is given as (32, ). 32 refers to the number of features in each input sample. Instead of not mentioning the batch-size, even a placeholder can be given.

What type of input data is best suited for RNN?

RNN is best suited for sequential data. It can handle arbitrary input / output lengths. RNN uses its internal memory to process arbitrary sequences of inputs.

Which neural network has only one hidden layer between the input and output?

Explanation : Shallow neural network : The Shallow neural network has only one hidden layer between the input and output.


1 Answers

What you need is Pointer Networks (https://arxiv.org/abs/1506.03134)

Here is a introduction quote from a post about it:

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. - https://finbarr.ca/pointer-networks/

Its an attention based model.

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

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

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

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 -

Input -

  1. Query
  2. Metadata of the table (column names)
  3. Token vocabulary for all categorical columns
  4. Keywords from SQL syntax (SELECT, WHERE etc..)

All of these are appended together.

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.

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.

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).

like image 104
Akshay Sehgal Avatar answered Sep 22 '22 05:09

Akshay Sehgal