2

For a multi-agent formation problem I want to use an Artificial Neural Network (ANN) which should output a desired velocity vector (x,y) based on the relative positions of neighbouring agents in view, either in (x,y) or (angle, radius) whichever will work best I guess.

The number of agents in view is variable since they only have ~150 degrees field of view.

How could I best deal with the variable number of inputs to the ANN? I would love some input on the best approach.

The only way I can think of is to limit the number of possible inputs and then either input only the closest neighbours when exceeding the limit or fill the empty inputs with fake neighbours far away (since distant interaction is very limited).

Wilco
  • 23
  • 4
  • 1
    Possible duplicate of [How can neural networks learn functions with a variable number of inputs?](http://stackoverflow.com/questions/31123257/how-can-neural-networks-learn-functions-with-a-variable-number-of-inputs) – Mohsen Kamrani Aug 25 '16 at 23:19

1 Answers1

3

Generally you can build your network with more inputs than you need. The important part is to make sure that your training data matches the usage data.

You can have a method where you simply input 0,0 for unused vectors, or you can make each input like x,y,0 where the last number is 1 if the vector should be used or not. The important thing is to just use lots of training data and make your real-world usage match the training format.

Inputs that aren't used or useful will tend towards zero weight in actual operation.

There are also more advanced methods where you take the output and loop it back into the input, then give one additional input on each iteration. That's probably overkill for what you're doing though.

Are you using reinforcement learning? Or supervised?

Kate66
  • 82
  • 2
  • Would the fact that there is a "repulsive force" between agents that gets increasingly larger with decreasing proximity limit the use of (0,0) as empty inputs? (Even though 0 distance is not a possible outcome in real-life) – Wilco Aug 25 '16 at 19:05
  • If you aren't using an on/off swich input, then you'll want to make the unused inputs look unimportant. How are you normalizing your inputs? For example, I would make the angle go from 0-1, and the distance go from 0 being very far away to 1 being very close. In that case you would put 0 for the distance on unused inputs. One easy way to normalize it is to make the input distance as `1/(actual distance)`. – Kate66 Aug 25 '16 at 19:08
  • 1
    Ah great I think that could work, thanks! Right now I was thinking of using [0 - camera_range] to normalise the distance, but the inverse distance solves the empty input problem much more gracefully. – Wilco Aug 25 '16 at 19:13
  • I tried but apparently don't have enough rep to get it displayed, so for now you'll have to make do with my written gratitude :p – Wilco Aug 25 '16 at 19:23
  • Haha, Well I'm in the same boat. Thanks! – Kate66 Aug 25 '16 at 19:24