Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to choose number of hidden layers and nodes in neural network? [closed]

What does number of hidden layers in a multilayer perceptron neural network do to the way neural network behaves? Same question for number of nodes in hidden layers?

Let's say I want to use a neural network for hand written character recognition. In this case I put pixel colour intensity values as input nodes, and character classes as output nodes.

How would I choose number of hidden layers and nodes to solve such problem?

like image 489
gintas Avatar asked Feb 24 '12 18:02

gintas


People also ask

How many hidden layers should I use in neural network?

Jeff Heaton (see page 158 of the linked text), who states that one hidden layer allows a neural network to approximate any function involving “a continuous mapping from one finite space to another.” With two hidden layers, the network is able to “represent an arbitrary decision boundary to arbitrary accuracy.”

How many nodes does a hidden layer have?

Because the first hidden layer will have hidden layer neurons equal to the number of lines, the first hidden layer will have four neurons. In other words, there are four classifiers each created by a single layer perceptron.

How does the number of hidden layers affect a neural network?

An inordinately large number of neurons in the hidden layers can increase the time it takes to train the network. The amount of training time can increase to the point that it is impossible to adequately train the neural network.

What happens if we increase number of hidden layers?

1) Increasing the number of hidden layers might improve the accuracy or might not, it really depends on the complexity of the problem that you are trying to solve. Where in the left picture they try to fit a linear function to the data.


3 Answers

Note: this answer was correct at the time it was made, but has since become outdated.


It is rare to have more than two hidden layers in a neural network. The number of layers will usually not be a parameter of your network you will worry much about.

Although multi-layer neural networks with many layers can represent deep circuits, training deep networks has always been seen as somewhat of a challenge. Until very recently, empirical studies often found that deep networks generally performed no better, and often worse, than neural networks with one or two hidden layers.

Bengio, Y. & LeCun, Y., 2007. Scaling learning algorithms towards AI. Large-Scale Kernel Machines, (1), pp.1-41.

The cited paper is a good reference for learning about the effect of network depth, recent progress in teaching deep networks, and deep learning in general.

like image 129
Don Reba Avatar answered Oct 14 '22 18:10

Don Reba


The general answer is to for picking hyperparameters is to cross-validate. Hold out some data, train the networks with different configurations, and use the one that performs best on the held out set.

like image 45
Rob Neuhaus Avatar answered Oct 14 '22 19:10

Rob Neuhaus


Most of the problems I have seen were solved with 1-2 hidden layers. It is proven that MLPs with only one hidden layer are universal function approximators (Hornik et. al.). More hidden layers can make the problem easier or harder. You usually have to try different topologies. I heard that you cannot add an arbitrary number of hidden layers if you want to train your MLP with backprop because the gradient will become too small in the first layers (I have no reference for that). But there are some applications where people used up to nine layers. Maybe you are interested in a standard benchmark problem which is solved by different classifiers and MLP topologies.

like image 40
alfa Avatar answered Oct 14 '22 17:10

alfa