Neural Networks: Machine Learning Is Machine Learning Is
Neural Networks: Machine Learning Is Machine Learning Is
Neural Networks
David Kauchak
CS30
Spring 2016
http://xkcd.com/894/
1
3/1/16
past future
t
n dic
le ar pr
e
Training model/ Testing model/
Data predictor Data predictor
induction
optimization
2
3/1/16
Data Data
examples examples
Data Data
Supervised learning
Data
examples
examples
label
label1
label5
3
3/1/16
label
label1
model/ model/
predictor predictor predicted label
label3
label4
label5
Supervised learning: given labeled examples Supervised learning: learn to predict new example
apple
Differentiate
Classification:
apple
a finite set of labels between low-risk
and high-risk
banana customers from
their income and
banana
savings
Supervised learning: given labeled examples
4
3/1/16
Regression Example
Regression Applications
Price of a used car Economics/Finance: predict the value of a stock
y = wx+w0 Epidemiology
x : car attributes
Car/plane navigation: angle of the steering wheel,
(e.g. mileage) acceleration, …
y : price
Temporal trends: weather over time
19
5
3/1/16
Unsupervised learning
Unsupervised learning
applications
learn clusters/groups without any label
image compression
6
3/1/16
Type of model:
! generative vs. discriminative
! parametric vs. non-parametric
http://www.youtube.com/watch?v=VCdxqn0fcnE
Neuron
What do you know?
7
3/1/16
8
3/1/16
Edge (synapses)
What are possible explanations?
" either neurons are performing some very complicated
computations
" brain is taking advantage of the massive parallelization
(remember, neurons are connected ~10,000 other neurons) our approximation
(neuron) (neuron)
9
3/1/16
A Single Neuron/Perceptron
Possible threshold functions
Input x1 Each input contributes:
Weight w1 xi * wi
hard threshold
"$ 1 if x ≥ threshold
g(x) = #
Weight w2
Input x2 $% 0 otherwise
∑ g(in) Output y
threshold function
Input x3
sigmoid
Weight w3 €
in = ∑ w i x i 1
€ g(x) =
Weight w4 i 1+ e−ax
Input x4
€ €
-1 -1
1
? 1
?
0 1
Threshold of 1 0 1
Threshold of 1
0.5 0.5
1 1 1*1 + 1*-1 + 0*1 + 1*0.5 = 0.5
10
3/1/16
-1 -1
1
0 0
?
Weighted sum is
0 1
Threshold of 1 0.5, which is not 0 1
Threshold of 1
larger than the
0.5 threshold 0.5
1 1 1*1 + 0*-1 + 0*1 + 1*0.5 = 1.5
Weighted sum is
0 1
Threshold of 1 1.5, which is
larger than the
0.5 threshold
1
11
3/1/16
inputs inputs
those answers
become inputs for
the next level
finally get the answer
after all levels compute
12
3/1/16
http://www.youtube.com/watch?v=Yq7d4ROvZ6I inputs
How?
Feed forward networks
13
3/1/16
0 0 0
OR – if at least one input is 1, return 1, otherwise
return 0 0 1 0
1 0 0
NOT – return the opposite of the input
1 1 1
XOR – if exactly one input is 1, then return 1,
otherwise return 0
14
3/1/16
x1 x2 x1 and x2 x1 x2 x1 and x2
AND 0 0 0 AND 0 0 0
0 1 0 0 1 0
Input x1 Input x1
1 0 0 1 0 0
W1 = ? W1 = 1
1 1 1 1 1 1
Input x2 W2 = ? Input x2 W2 = 1
AND AND
Input x1 Input x1
W1 = ? W1 = 1
W2 = ? W2 = 1
Input x2 Input x2
T=? Output y T=4 Output y
Output is 1 only if
all inputs are 1
Input x3 W3 = ? Input x3 W3 = 1
W4 = ? W4 = 1
Input x4 Input x4
15
3/1/16
x1 x2 x1 or x2
OR OR 0 0 0
Input x1 0 1 1
x1 x2 x1 or x2 W1 = ? 1 0 1
1 1 1
0 0 0
Output y
0 1 1 T=?
1 0 1
Input x2 W2 = ?
1 1 1
x1 x2 x1 or x2
OR 0 0 0 OR
Input x1
Input x1 0 1 1
W1 = ?
W1 = 1 1 0 1
1 1 1
W2 = ?
Input x2
T=1 Output y T=? Output y
Output is 1 if at
least 1 input is 1
Input x3 W3 = ?
Input x2 W2 = 1
Inputs are either 0 or 1
W4 = ?
Input x4
16
3/1/16
OR NOT
Input x1
W1 = 1
x1 not x1
Input x2
W2 = 1 0 1
T=1 Output y
Output is 1 if at
least 1 input is 1 1 0
Input x3 W3 = 1
W4 = 1
Input x4
Inputs are either 0 or 1
x1 not x1
NOT 0 1 NOT
1 0
W1 = ? W1 = -1
Input x1 T=? Output y Input x1 T=0 Output y
Input is either 0 or 1 If input is 1, output is 0.
If input is 0, output is 1.
17
3/1/16
x1 x2 x3 x1 and
x2
0 0 0 1
Input x1
0 1 0 0 w1 = ?
w =?
1 0 0 1 Input x2 2
T=? Output y Learn individual
1 1 0 0 node parameters
Input x3 Learn the individual
0 0 1 1 w3 = ? (e.g. threshold)
weights between nodes
0 1 1 1
1 0 1 1
1 1 1 0
NEGATIVE NEGATIVE
18
3/1/16
POSITIVE NEGATIVE
POSITIVE POSITIVE
19
3/1/16
NEGATIVE POSITIVE
20
3/1/16
Perceptron learning
Perceptron learning algorithm Weighted sum is
1
0.5, which is not
1 equal or larger than
repeat until you get all examples right: the threshold
predicted
-1
- for each “training” example:
- calculate current prediction on example
1
0
- if wrong: actual
0 1
Threshold of 1
update weights and threshold towards getting this
1
-
example correct
0.5
1
What could we adjust to make it right?
predicted predicted
-1 -1
1
0 1
0
0 1 actual 0 1 actual
Threshold of 1 Threshold of 1
0.5
1 0.5
1
1 1
This weight doesn’t matter, so don’t change Could increase any of these weights
21
3/1/16
0.5
1
1
Could decrease the threshold
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 1 0 0 1 1 0 1 1 0 1 0 0 1 1 0 1 1
1 0 0 1 0 1 1 0 1 1 0 0 1 0 1 1 0 1
1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 0
22
3/1/16
Perceptrons XOR
?
Input x1 T=?
1969 book by Marvin Minsky and Seymour Papert ?
Output = x1 xor x2
? T=?
?
The problem is that they can only work for
classification problems that are linearly separable T=?
?
Input x2 ?
x1 x2 x1 xor x2
Insufficiently expressive
0 0 0
0 1 1
“Important research problem” to investigate
multilayer networks although they were pessimistic 1 0 1
about their value 1 1 0
XOR
1
Input x1 T=1
1
Output = x1 xor x2
-1 T=1
-1
Input x2 T=1
1
x1 x2 x1 xor x2
0 0 0
0 1 1
1 0 1
1 1 0
23