Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining the proper amount of Neurons for a Neural Network

I have been doing some research with neural networks and the concept and theory as a whole makes sense to me. Although the one question that sticks out to me, which I haven't been able to find an answer to yet, is how many neurons should be used in a Neural Net. to achieve proper/efficient results. Including Hidden Layers, neurons per Hidden Layer, etc. Do more neurones necessarily more accurate results (while being more taxing on the system) or will less neurons still be sufficient? Is there some sort of governing rule to help determine those numbers? Does it depend on the type of training/learning algorithm that is being implemented into the neural net. Does it depend on the type of data/input that is being presented to the network?

If it makes it easier to answer the questions, I will most likely be using feedforwarding and backpropogation as the main method for training and prediction.

On a side note, is there a prediction algorithm/firing rule or learning algorithm that is generally regraded to as "the best/most practical", or is that also dependant on the type of data being presented to the network?

Thanks to anyone with any input, it's always appreciated!

EDIT: Regarding the C# tag, that is the language in which I'll be putting together my neural network. If that information helps at all.

like image 811
cAstronaut Avatar asked Oct 07 '22 10:10

cAstronaut


2 Answers

I specialized in AI / NN in College, and have had some ameture experience working on them for games, and here is what I found as a guide for getting started. Realize, however, that each NN will take some tweaking to work best in your chosen environment. (One potential solution is to expose your program to 1000s of different NNs, setup a testable criteria for performance and then use a Genetic Algorithm to propagate more useful NNs and cull less useful NNs - but that is a whole other very large post...)

I found - in general

  • Input Layer - One AN for each input vector + 1 Bias (always 1)
  • Inner Layer - Double the Input Layer
  • Output Layer - One AN for each Action or Result

Example: Character Recognition

  • If you are examining a 10x10 grid for character recognition;
  • start with 101 Input AN (one for each pixel, plus one bias)
  • 202 Inner AN
  • and 26 Output AN (one for each letter of the alphabet)

Example: Blackjack

  • If you are building a NN to "win at blackjack";
  • start with 16 Input AN (13 to count each occurance of a card, 1 for player hand value, 1 for dealer "up-card", and 1 bias)
  • 32 Inner AN
  • and 6 output AN (one for "Hit" "Stay" "Split" "Double" "Surrender" and "Insurrance")
like image 128
EtherDragon Avatar answered Oct 13 '22 10:10

EtherDragon


Some general rules are the following based on this paper: 'Approximating Number of Hidden layer neurons in Multiple Hidden Layer BPNN Architecture' by Saurabh Karsoliya. Source here

  • The number of hidden layer neurons are 2/3 (or 70% to 90%) of the size of the input layer. If this is insufficient then number of output layer neurons can be added later on.
  • The number of hidden layer neurons should be less than twice of the number of neurons in input layer.
  • The size of the hidden layer neurons is between the input layer size and the output layer size.
like image 20
seralouk Avatar answered Oct 13 '22 11:10

seralouk