nyvaken
nyvaken

Reputation: 120

Neural network, minimum number of neurons

I've got a 2D surface where a ship (with constant speed) navigates around the scene to pick up candy. For every candy the ship picks up I increase the fitness. The NN has one output to steer the ship (0 for left and 1 for right, so 0.5 would be straight forward) There are four inputs in the range [-1 .. 1], that represents two normalized vectors. The ship direction and the direction to the piece of candy.

Is there any way to calculate the minimum number of neurons in the hidden layer? I also tried giving two inputs instead of four, the first was the dot product [-1..1] (where I dotted the ship direction with the direction to the candy) and the second was (0/1) if the candy was to the left/right of the ship. It seems like this approach worked a lot better with fewer neurons in the hidden layer.

Upvotes: 2

Views: 1269

Answers (2)

Felipe Oriani
Felipe Oriani

Reputation: 38598

Defining the number of hidden layers and the number of neurons in each hidden layers always was a challenge and it may diverge from each type of problems. By the way, a single hidden layer in a feedforward neural network could solve most of the problems, given it can aproximate functions.

Murata defined some rules to use in neural networks to define the number of hidden neurons in a feedforward neural network:

  • The value should be between the size of the input and output layers.
  • The value should be 2/3 the size of the input layer plus the size of the output layer.
  • The value should be less than twice the size of the input layer

You could try these rules and evaluate the impact of it in your neural network.

Upvotes: 1

Mido
Mido

Reputation: 665

Fewer inputs should imply fewer number of neurons. This is because the number of input combinations decrease and it gets easier for the neural network to learn the system. There is no golden rule as to how to calculate the best number of nodes in the hidden layer. However, with 2 inputs I'd say 2 hidden nodes should work fine. It really depends on the degree of non linearity in your inputs.

Upvotes: 2

Related Questions