<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264421</link>
    <title>MATLAB Central Newsreader - Question about number of layers in ANN</title>
    <description>Feed for thread: Question about number of layers in ANN</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Thu, 29 Oct 2009 08:15:23 -0400</pubDate>
      <title>Question about number of layers in ANN</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264421#690545</link>
      <author>Kloser </author>
      <description>Dear All&lt;br&gt;
I want to know, in Neural Networks, whether more layers will promise higher accuracy for classification?&lt;br&gt;
I have tried using two networks to classify some images into classes. There are 100 variables in each sample, meaning that there are 100 input nodes. And for the Networks, The 1-layer network have 60 output nodes, and the 2-layers network have 20 hidden nodes in the hidden layers and 60 output nodes. &lt;br&gt;
But I found that the accuracy in the 1-layer network is higher than that in the 2-layer. I expected that the 2-layer may have higher accuracy because there are more parameters, so I am wondering whether there are bugs in my implementation. But I can't find any bugs up to now.&lt;br&gt;
So can anyone tell me if that is my wrong expectation or other reasons so I have this result? And what is the relationship between the numbers of layers and the accuracy? How should I judge the optimal numbers of layers for neural networks?&lt;br&gt;
Thank you</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 08:24:06 -0400</pubDate>
      <title>Re: Question about number of layers in ANN</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264421#690548</link>
      <author>Gavrilo Bozovic</author>
      <description>&quot;Kloser &quot; &amp;lt;kcfcheung@gmail.com&amp;gt; wrote in message &amp;lt;hcbiur$5g7$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Dear All&lt;br&gt;
&amp;gt; I want to know, in Neural Networks, whether more layers will promise higher accuracy for classification?&lt;br&gt;
&amp;gt; I have tried using two networks to classify some images into classes. There are 100 variables in each sample, meaning that there are 100 input nodes. And for the Networks, The 1-layer network have 60 output nodes, and the 2-layers network have 20 hidden nodes in the hidden layers and 60 output nodes. &lt;br&gt;
&amp;gt; But I found that the accuracy in the 1-layer network is higher than that in the 2-layer. I expected that the 2-layer may have higher accuracy because there are more parameters, so I am wondering whether there are bugs in my implementation. But I can't find any bugs up to now.&lt;br&gt;
&amp;gt; So can anyone tell me if that is my wrong expectation or other reasons so I have this result? And what is the relationship between the numbers of layers and the accuracy? How should I judge the optimal numbers of layers for neural networks?&lt;br&gt;
&amp;gt; Thank you&lt;br&gt;
&lt;br&gt;
If you have more layers, you will have a higher accuracy for classification, but only if you have an extended training set.&lt;br&gt;
&lt;br&gt;
If you can't train your neural network on enough inputs, adding layers won't help, on the contrary.</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 08:37:02 -0400</pubDate>
      <title>Re: Question about number of layers in ANN</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264421#690550</link>
      <author>Kloser </author>
      <description>Thank you, Gavrilo,&lt;br&gt;
But could you please provide some more detail about the relationship between the input and the number of layers?&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;Gavrilo Bozovic&quot; &amp;lt;gavrilo.dot.bozovic@gmail.dot.ch&amp;gt; wrote in message &amp;lt;hcbjf6$a7o$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;Kloser &quot; &amp;lt;kcfcheung@gmail.com&amp;gt; wrote in message &amp;lt;hcbiur$5g7$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Dear All&lt;br&gt;
&amp;gt; &amp;gt; I want to know, in Neural Networks, whether more layers will promise higher accuracy for classification?&lt;br&gt;
&amp;gt; &amp;gt; I have tried using two networks to classify some images into classes. There are 100 variables in each sample, meaning that there are 100 input nodes. And for the Networks, The 1-layer network have 60 output nodes, and the 2-layers network have 20 hidden nodes in the hidden layers and 60 output nodes. &lt;br&gt;
&amp;gt; &amp;gt; But I found that the accuracy in the 1-layer network is higher than that in the 2-layer. I expected that the 2-layer may have higher accuracy because there are more parameters, so I am wondering whether there are bugs in my implementation. But I can't find any bugs up to now.&lt;br&gt;
&amp;gt; &amp;gt; So can anyone tell me if that is my wrong expectation or other reasons so I have this result? And what is the relationship between the numbers of layers and the accuracy? How should I judge the optimal numbers of layers for neural networks?&lt;br&gt;
&amp;gt; &amp;gt; Thank you&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If you have more layers, you will have a higher accuracy for classification, but only if you have an extended training set.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If you can't train your neural network on enough inputs, adding layers won't help, on the contrary.</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 16:00:08 -0400</pubDate>
      <title>Re: Question about number of layers in ANN</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264421#690705</link>
      <author>Gavrilo Bozovic</author>
      <description>The more you have layers, the more axons and synapses you have, and therefore the more parameters you can tune.&lt;br&gt;
&lt;br&gt;
But to be able to tune them, you need to have a lot of input data.&lt;br&gt;
&lt;br&gt;
Take thi: if you have a series of ten thousand points in 2d, you can fit a 10th order polynom if it approximates better your series.&lt;br&gt;
&lt;br&gt;
But if you have only two points, there's no use to try fitting a polynom of an order superior to two, although it is theoretically possible.&lt;br&gt;
&lt;br&gt;
That's the same for your network : if you have a too reduced training set, you won't be able to tune the parameters of a large model satisfactorily.</description>
    </item>
    <item>
      <pubDate>Thu, 29 Oct 2009 17:07:02 -0400</pubDate>
      <title>Re: Question about number of layers in ANN</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/264421#690743</link>
      <author>Greg Heath</author>
      <description>On Oct 29, 4:15 am, &quot;Kloser &quot; &amp;lt;kcfche...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; Dear All&lt;br&gt;
&amp;gt; I want to know, in Neural Networks, whether morelayerswill promise higher accuracy&lt;br&gt;
&amp;gt; for classification?&lt;br&gt;
&lt;br&gt;
No. Just, perhaps, fewer weights.&lt;br&gt;
&lt;br&gt;
&amp;gt; I have tried using two networks to classify some images into classes. There are 100&lt;br&gt;
&amp;gt;  variables in each sample, meaning that there are 100 input nodes. And for the&lt;br&gt;
&amp;gt;  Networks, The 1-layer network  have 60 output nodes,&lt;br&gt;
&lt;br&gt;
The 1-layer network is equivalent to a linear or logistic model.&lt;br&gt;
What is the output transfer function?&lt;br&gt;
How large is your training sample?&lt;br&gt;
&lt;br&gt;
For I = 100 inputs,  and O=60 outputs you will have Nw = (I+1)*O =&lt;br&gt;
6060 unknown&lt;br&gt;
weights. With Ntrn training samples you will have Neq = Ntrn*O =&lt;br&gt;
60*Ntrn equations.&lt;br&gt;
&lt;br&gt;
To mitigate noise and measurement error it is desirable to have&lt;br&gt;
&lt;br&gt;
Neq &amp;gt;&amp;gt; Nw&lt;br&gt;
&lt;br&gt;
or&lt;br&gt;
&lt;br&gt;
Ntrn &amp;gt;&amp;gt; (I+1) = 101; e.g., Ntrn ~1000 to 3000&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;gt; and the 2-layersnetwork have 20 hidden nodes in the hiddenlayersand 60 output&lt;br&gt;
&amp;gt; nodes&lt;br&gt;
&lt;br&gt;
What are the hidden and output transfer functions?&lt;br&gt;
&lt;br&gt;
A NN with 1 hidden laye rwith H nodes is a universal approximator&lt;br&gt;
provided H is&lt;br&gt;
sufficiently large. Since there is no known analytical expression for&lt;br&gt;
determining the&lt;br&gt;
optimal number of hidden nodes, it is usually chosen by trial and&lt;br&gt;
error.&lt;br&gt;
&lt;br&gt;
How was H = 20 determined? Are you sure it is sufficiently large?&lt;br&gt;
&lt;br&gt;
If H for one hidden layer is sufficiently large, the total number of&lt;br&gt;
hidden nodes&lt;br&gt;
can be reduced by adding more hidden layers. However, there is no&lt;br&gt;
known analytical&lt;br&gt;
expression for determining H1 or H2. The best bet is to use a single&lt;br&gt;
hidden layer&lt;br&gt;
unless there is a priori information on what H1 or H2 should be. Then&lt;br&gt;
the other can be&lt;br&gt;
found by trial and error.&lt;br&gt;
&lt;br&gt;
For a single hidden layer with H=20 nodes, you will have&lt;br&gt;
&lt;br&gt;
Nw = (I+1)*H+(H+1)*O = O+(I+O+1)*H = 60+(161)*20 = 3280 unknown&lt;br&gt;
weights.&lt;br&gt;
&lt;br&gt;
Therefore it is desrable to have&lt;br&gt;
&lt;br&gt;
Ntrn &amp;gt;&amp;gt; Nw/O = 3220/60 ~ 55, e.g., Ntrn ~ 550 to 165&lt;br&gt;
&lt;br&gt;
.&lt;br&gt;
&amp;gt; But I found that the accuracy in the 1-layer network is higher than that in the 2-layer. &amp;gt; I expected   that the 2-layer may have higher accuracy because there are more  parameters,&lt;br&gt;
&lt;br&gt;
WRONG. Your single layer has twice as many weights.!&lt;br&gt;
&lt;br&gt;
&amp;gt; so I am wondering whether there are bugs in my implementation. But I can't find any &amp;gt; bugs up to now.&lt;br&gt;
&lt;br&gt;
How about the choice H = 20?&lt;br&gt;
Again, what is Ntrn?&lt;br&gt;
&lt;br&gt;
&amp;gt; So can anyone tell me if that is my wrong expectation or other reasons so I have this &amp;gt; result? And what is the relationship between the numbers oflayersand the accuracy? &amp;gt; How should I judge the optimal numbers oflayersfor neural networks?&lt;br&gt;
&lt;br&gt;
1 hidden layer is usually sufficient. Sometime it is not necessary.&lt;br&gt;
I always design a linear model before designing a NN with a&lt;br&gt;
single hidden layer.&lt;br&gt;
&lt;br&gt;
See my post on Pretraining Advice&lt;br&gt;
See the comp.ai.neural-nets FAQ&lt;br&gt;
Search in comp.ai.neural-nets and comp.soft-sys.matlab&lt;br&gt;
using &quot;number of layers&quot;&lt;br&gt;
&lt;br&gt;
Hope this helps.&lt;br&gt;
&lt;br&gt;
Greg</description>
    </item>
  </channel>
</rss>

