Neural Nets 2: Difference between revisions

From bradwiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 5: Line 5:
4. [[Neural Nets 4|Network Outputs]]<br>
4. [[Neural Nets 4|Network Outputs]]<br>
}}
}}
<br><br><br><br><br><br>
<br><br><br><br><br><br>
<br><br><br><br><br><br>


==TBD BELOW==
On the previous page we discussed
 
 
Here is the full set of possible network inputs we have here, which includes...
 
{| class="wikitable" width=30% align=center
|+ style="font-weight:bold;"|Input Features
|- style="height:30px"
| style="background:#f7f7f7; border:3px solid #ffffff"| ''X''<sub>1</sub>
|colspan=2 style="background:#f7f7f7; border:3px solid #ffffff"| AGE
|- style="height:30px"
| style="background:#f7f7f7; border:3px solid #ffffff"| ''X''<sub>2</sub> 
|colspan=2 style="background:#f7f7f7; border:3px solid #ffffff"|  SCORE
|- style="height:30px"
| style="background:#f7f7f7; border:3px solid #ffffff"| ''X''<sub>1</sub><sup>2</sup>
|colspan=2 style="background:#f7f7f7; border:3px solid #ffffff"|  AGE<sup>2</sup>
|- style="height:30px"
| style="background:#f7f7f7; border:3px solid #ffffff"| ''X''<sub>2</sub><sup>2</sup>
|colspan=2 style="background:#f7f7f7; border:3px solid #ffffff"|  SCORE<sup>2</sup>
|- style="height:30px"
| style="background:#f7f7f7; border:3px solid #ffffff"| ''X''<sub>1</sub>''X''<sub>2</sub>
|colspan=2 style="background:#f7f7f7; border:3px solid #ffffff"|  AGE × SCORE
|- style="height:30px"
| style="background:#f7f7f7; border:3px solid #ffffff"| sin(''X''<sub>1</sub>)
|colspan=2 style="background:#f7f7f7; border:3px solid #ffffff"|  sin(AGE)
|- style="height:30px"
| style="background:#f7f7f7; border:3px solid #ffffff"| sin(''X''<sub>2</sub>)
|colspan=2 style="background:#f7f7f7; border:3px solid #ffffff"|  sin(SCORE)
|}
 
 
 
 
{{#widget:Tensorflow2}}
 
 
 
 
 
 
 
 
 
===Inputs===
----
 
Take a close look at the input options in Figure-1 on the right. There are a bunch of ''X'' variables with subscripts and superscripts, and next to each is a box with various color gradients. For now, let's focus on just two of those symbols, and what they mean to us...
 
{| class="wikitable" width=30% align=center
|+ style="font-weight:bold;"|Input Features
|- style="height:30px"
| style="background:#f7f7f7; border:3px solid #ffffff"| ''X''<sub>1</sub>
|colspan=2 style="background:#f7f7f7; border:3px solid #ffffff"| AGE
|- style="height:30px"
| style="background:#f7f7f7; border:3px solid #ffffff"| ''X''<sub>2</sub> 
|colspan=2 style="background:#f7f7f7; border:3px solid #ffffff"|  SCORE
|}
 
These are parsed such that subscripts (''X''<sub>1</sub> , ''X''<sub>2</sub> ,... ''X''<sub>i</sub> ) represent each predictor variable, like AGE and SCORE. As you can see, the first two input options ''X''<sub>1</sub> and ''X''<sub>2</sub> are just ''X''<sub>AGE</sub> and ''X''<sub>SCORE</sub>. Note that since ''X''<sub>1</sub> is plotted on the x-axis, it has a color gradient that changes horizontally, but is constant in the vertical dimension. Conversely the ''X''<sub>2</sub> feature plotted on the y-axis has a vertical color gradient. To clarify why this happens...
 
If the only thing we know about these study participants is their AGE, ''X''<sub>1</sub>, we can only make a 1-D plot with each person's age along the x-axis, such that [ x = ''AGE''<sub>i</sub> , y = 0 ]. If you take a look at Figure-2, it should be clear that when information is collapsed onto its single dimension and plotted along the x-axis, the best line we can draw to separate the dim-1 data will be orthogonal to the x-axis (a vertical line). As you move horizontally along the x-axis your categorical guess will likely change, along with the confidence in that guess, which is precisely what is being represented by the color gradient. On the other hand, knowing nothing about exam score, moving up and down on the y-axis will have no effect on your decision, which is why color is constant in the y-dimension.
 
When the neural net only gets input about a single feature of each person in the dataset, its synaptic weights will only adapt output along that one dimension. Thus, if for example the network sees that a person is 3 years above the dataset average (considering the data has been ''mean deviated'' and centered), it won't matter what that person's cognitive SCORE was (since the neural net doesn't have access to that info), the network will always make the same guess for anyone 3 years above average age. This is why color is constant at ''x''=3 for any ''y'' value.
 
{{SmallBox|display=block
|float=right
|clear=none
|width=420px
|margin=25px -10% 5px 10px
|border-width=2px
|border-radius=2px
|[[File:NN NumberLine.png|400px]]
| Figure 2
}}
 
This isn't a shortcoming of having just one single neuron in the entire network. You could add as many neurons and layers as you want (go ahead and try it)...... if the network only gets input about one feature dimension, the output will be the same, whether there is 1 neuron, or 1 billion. To realize this fact, pretend you can only see the dots as they are plotted in along the number line in 1D (in Figure 2); if we were unable to see the 2D cluster clouds above that line, the billions of neurons in our brain would tell us to draw the classification line in basically the same place as that one single neuron in our artificial neural net. This is a very interesting concept worth noting: neural net classifiers can fail for two very different reasons.
 
(1) The neural network itself might be ill-formulated in such a way that, no matter how much information you provide, it cannot seem to learn to solve the classification problem. (2) On the other hand, you might have implemented an apposite deep neural network; yet if the input data is insufficient to solve the classification problem, it will appear to you that this potentially very good neural network performs like garbage. <br>
 
{{Quote|A perfectly capable neural net might end up performing like garbage because, with the info you were feeding in, it never stood a chance.|source=anonymous social worker}} <br><br>
 
With that said, there are ways to help prevent that later scenario from happening. These involve doing things like you see for the rest of the input features.
 
 
<br>
{{SmallBox|'''[[Neural Nets 2|Continue to Neural Nets Tutorial Page 2]]'''}}
 
<!-- <btn data-toggle="tooltip">Neural Nets 2</btn> -->
 
 
 
 
 
 


Below I've embedded another Tensorflow neural net playground.  
Below I've embedded another Tensorflow neural net playground.  


{{#widget:Tensorflow}}
 





Revision as of 15:30, 22 January 2018

TUTORIAL ON MACHINE LEARNING AND NEURAL NETWORKS (PAGE 2)

Tutorial Pages







On the previous page we discussed


Here is the full set of possible network inputs we have here, which includes...

Input Features
X1 AGE
X2 SCORE
X12 AGE2
X22 SCORE2
X1X2 AGE × SCORE
sin(X1) sin(AGE)
sin(X2) sin(SCORE)



{{#widget:Tensorflow2}}





Inputs


Take a close look at the input options in Figure-1 on the right. There are a bunch of X variables with subscripts and superscripts, and next to each is a box with various color gradients. For now, let's focus on just two of those symbols, and what they mean to us...

Input Features
X1 AGE
X2 SCORE

These are parsed such that subscripts (X1 , X2 ,... Xi ) represent each predictor variable, like AGE and SCORE. As you can see, the first two input options X1 and X2 are just XAGE and XSCORE. Note that since X1 is plotted on the x-axis, it has a color gradient that changes horizontally, but is constant in the vertical dimension. Conversely the X2 feature plotted on the y-axis has a vertical color gradient. To clarify why this happens...

If the only thing we know about these study participants is their AGE, X1, we can only make a 1-D plot with each person's age along the x-axis, such that [ x = AGEi , y = 0 ]. If you take a look at Figure-2, it should be clear that when information is collapsed onto its single dimension and plotted along the x-axis, the best line we can draw to separate the dim-1 data will be orthogonal to the x-axis (a vertical line). As you move horizontally along the x-axis your categorical guess will likely change, along with the confidence in that guess, which is precisely what is being represented by the color gradient. On the other hand, knowing nothing about exam score, moving up and down on the y-axis will have no effect on your decision, which is why color is constant in the y-dimension.

When the neural net only gets input about a single feature of each person in the dataset, its synaptic weights will only adapt output along that one dimension. Thus, if for example the network sees that a person is 3 years above the dataset average (considering the data has been mean deviated and centered), it won't matter what that person's cognitive SCORE was (since the neural net doesn't have access to that info), the network will always make the same guess for anyone 3 years above average age. This is why color is constant at x=3 for any y value.

Error creating thumbnail: File missing
Figure 2


This isn't a shortcoming of having just one single neuron in the entire network. You could add as many neurons and layers as you want (go ahead and try it)...... if the network only gets input about one feature dimension, the output will be the same, whether there is 1 neuron, or 1 billion. To realize this fact, pretend you can only see the dots as they are plotted in along the number line in 1D (in Figure 2); if we were unable to see the 2D cluster clouds above that line, the billions of neurons in our brain would tell us to draw the classification line in basically the same place as that one single neuron in our artificial neural net. This is a very interesting concept worth noting: neural net classifiers can fail for two very different reasons.

(1) The neural network itself might be ill-formulated in such a way that, no matter how much information you provide, it cannot seem to learn to solve the classification problem. (2) On the other hand, you might have implemented an apposite deep neural network; yet if the input data is insufficient to solve the classification problem, it will appear to you that this potentially very good neural network performs like garbage.



With that said, there are ways to help prevent that later scenario from happening. These involve doing things like you see for the rest of the input features.



Continue to Neural Nets Tutorial Page 2





Below I've embedded another Tensorflow neural net playground.







Outputs


More directly, it is the value spit-out by the activation function of the 'output layer'. Here, since we only have a single layer, our hidden 'hidden layer' and 'output layer' are one in the same. The output function of our neuron is known as the tanh function.

The tanh function is an extremely common choice for an output function in artificial neural network machine learning frameworks because it yields a nice sigmoid shape, and no matter the magnitude of its inputs, the output from the tanh function is bounded between { 0 : 1}. These are very desirable properties for neural net nodes. Here you see the tanh function evaluated across various x-dim inputs...






Error creating thumbnail: File missing
see tanh on wolfram alpha for many details about tanh function.

Tanh produces a sigmoid output over the range {-2 : 2}, and automatically evaluates to exact values when its argument is the natural logarithm. Speaking of the natural log, that is another very common choice of output function for the same reasons as tanh.

For now, let's not belabor the point that our neuron (and in going forward, all our neurons) are using the tanh function. Maybe just keep this in mind if you're wondering what sorts of numbers are travelling along the axons of these neurons, and ultimately those colored gradients underneath the dots.

This tutorial continues on the next page. Don't worry about playing around too much with the TensorFlow GUI, there will be plenty of that on the next page, and those that follow.