Clear Filters
Clear Filters

Very confusted about the number of input neurons in my network.

1 view (last 30 days)
Hello,
I believe this to be an elementary question to more experienced machine learning experts, but I am lost. I know that the number of input neurons corresponds to your input layers in a neural network. However, I am still confused about how many input neurons I have in my network.
Here is my case:
I am performing a classification problem where I am trying to classify shapes. I have circles, squares, and triangles.
For my input data, I have 100 samples of each shape (300 total samples). Additionally, each sample has 50 attributes (predictors/elements) that describe the shape.
I end up with a 50*300 matrix that I am feeding into the network.
My question is, how many input neurons do I have? Would it be 50, 100, or 300?
I will be grateful for your response.

Accepted Answer

Greg Heath
Greg Heath on 4 Oct 2017
[ I N ] = size(input) % [ 50 300 ]
[ O N ] = size(target) % [ 3 300 ]
target columns are columns of eye(3)
Take a look at my QUICKIES codes in the NEWSREADER.
greg quickies
This is a great way to get a quick feel for the problem before you try multiple random weight initializations trying to find the smallest successful number of hidden nodes.
Hope this helps.
Thank you for formally accepting my answer
Greg
  1 Comment
ampaul
ampaul on 4 Oct 2017
Edited: Greg Heath on 5 Oct 2017
> Thank you, Greg, but the reason I am asking this is so I can choose my hidden layer size. I am choosing my hidden layer size based on the mean of the number of output neurons and input neurons.
NO !!!
1. INPUT LAYER NODES ARE NOT NEURONS!
They are just FAN-IN UNITS!
The number of input nodes, I, are determined by the number of "I"nput variables, I.
[ I N ] = size(input)
2. OUTPUT LAYER NODES ARE NEURONS!
The number of output neurons, O, are determined by the number of "O"utput target variables, O
[ O N ] = size(target)
3. I have written ZILLIONS (OK, maybe just HUNDREDS) of NEWREADER and ANSWERS posts on how to choose the number of hidden nodes, H, in the hidden layer.
4. Minimize H subject to the constraints
a. mse(error) <= 0.01*mean(var(target',1))
b. H <= Hmax <= Hub = (Ntrn-1)*O/(I+O+1)
5. Subsets of
greg Hmax Hub Ntrials
should suffice for searching.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!