Department of Computer Science and Engineering, IIT Madras
Artificial Neuron
$$x_1$$
$$w_1$$
$$x_2$$
$$x_3$$
$$y_1$$
$$\sigma$$
$$w_2$$
$$w_3$$
https://cdn.vectorstock.com/i/composite/12,25/neuron-cell-vector-81225.jpg
soma
dendrite
axon
synapse
fires if visual is funny
fires if speech style is funny
fires if text is funny
fires if at least 2 of 3 inputs fired
________________________________________
face
nose
mouth
eyes
Ā |
---|
\(y=f(g(x)) = 1\)Ā Ā Ā ifĀ Ā \(g(x) \geqĀ Ā \theta\)
Ā \(= 0\)Ā Ā Ā ifĀ Ā \(g(x) <Ā Ā \theta\)
A McCulloch Pitts unit
3
1
0
1
0
AND function
OR function
\(x_1\) ANDĀ !\(x_2\)*
NOR function
NOT function
1
OR function
AND function
2
Tautology (always ON)
0
1
OR
\(x_1 + x_2 + x_3= \theta = 1\)
Ā |
---|
Ā |
---|
$$x_1$$
$$x_2$$
$$x_n$$
$$y$$
$$w_1$$
$$w_2$$
$$w_n$$
$$..$$
$$..$$
$$..$$
$$..$$
$$x_0=1$$
$$w_0=-\theta$$
$$x_1$$
$$w_1$$
$$x_2$$
$$x_n$$
$$w_2$$
$$w_n$$
$$..$$
$$..$$
$$..$$
$$..$$
$$y$$
$$x_1$$
$$w_1$$
$$x_2$$
$$y$$
$$w_2$$
$$w_3$$
$$x_0=1$$
$$w_0=-\theta$$
$$x_3$$
$$x_1$$
$$w_1$$
$$x_2$$
$$y$$
$$w_2$$
$$w_3$$
$$x_0=1$$
$$w_0=-\theta$$
$$x_3$$
McCulloch Pitts Neuron
Perceptron
\(x_1\)
\(x_2\)
OR
\(0\)
\(1\)
\(0\)
\(1\)
\(0\)
\(0\)
\(1\)
\(1\)
\(0\)
\(1\)
\(1\)
\(1\)
\(-1\)
\(-1\)
\(3\)
\(1.5\)
\(0\)
\(1\)
\(0.45\)
\(0.45\)
\(3\)
...
...
(scaled to 0 to 1)
(scaled to 0 to 1)
$$w_1$$
$$w_2$$
$$w_n$$
$$..$$
$$..$$
$$w_0=-\theta$$
$$x_1$$
$$x_2$$
$$x_n$$
$$y$$
$$..$$
$$..$$
$$x_0=1$$
\(P \gets\) \(inputs\) \(with\) \(label\)Ā \(1\);
\(N \gets\) \(inputs\) \(with\) \(label\)Ā \(0\);
Initialize \(\text w\)Ā randomly;
while \(!convergence\)Ā do
Pick random \(\text x\)Ā \(\isin\) \( P\)Ā \(\cup\) \( N\)Ā Ā ;
\(\text w\) = \(\text w\)Ā \(+\) \(\text x\) ;
end
end
//the algorithm converges when all the inputs
Ā Ā are classified correctly
if \(\text x\) \(\isin\) \(\text P\) Ā \(and\) Ā \(\sum_{i=0}^{n}\ w_i*x_iĀ < 0\) then
end
if \(\text x\) \(\isin\) \(\text N\)Ā \(and\) Ā \(\sum_{i=0}^{n}\ w_i*x_iĀ \geq 0\) then
\(\text w\) = \(\text w\)Ā \(-\) \(\text x\) ;
(\(\because\) \(cos \alpha \)= \({w^Tx\over \parallel w \parallel \parallel x \parallel}\) Ā = \(0\))
\(y = 1\)Ā Ā Ā Ā \(ifĀ Ā Ā Ā Ā Ā \text w^\text T \text x \geq 0\)
\( = 0\)Ā Ā Ā Ā \(ifĀ Ā Ā Ā Ā Ā \text w^\text T \text x < 0\)
\(x_2\)
\(x_1\)
\(p_2\)
\(p_3\)
\(\text w\)
\(p_1\)
\(n_1\)
\(n_2\)
\(n_3\)
\(P \gets\) \(inputs\) \(with\) \(label\)Ā \(1\);
\(N \gets\) \(inputs\) \(with\) \(label\)Ā \(0\);
Initialize \(\text w\)Ā randomly;
while \(!convergence\)Ā do
Pick random \(\text x\)Ā \(\isin\) \( P\)Ā \(\cup\) \( N\)Ā Ā ;
\(\text w\) = \(\text w\)Ā \(+\) \(\text x\) ;
end
end
//the algorithm converges when all the inputs
Ā Ā are classified correctly
if \(\text x\) \(\isin\) \(\text P\) Ā \(and\) Ā \(\sum_{i=0}^{n}\ w_i*x_iĀ < 0\) then
end
if \(\text x\) \(\isin\) \(\text N\)Ā \(and\) Ā \(\sum_{i=0}^{n}\ w_i*x_iĀ \geq 0\) then
\(\text w\) = \(\text w\)Ā \(-\) \(\text x\) ;
\(P \gets\) \(inputs\) \(with\) \(label\)Ā \(1\);
\(N \gets\) \(inputs\) \(with\) \(label\)Ā \(0\);
Initialize \(\text w\)Ā randomly;
while \(!convergence\)Ā do
Pick random \(\text x\)Ā \(\isin\) \( P\)Ā \(\cup\) \( N\)Ā Ā ;
\(\text w\) = \(\text w\)Ā \(+\) \(\text x\) ;
end
end
//the algorithm converges when all the inputs
Ā Ā are classified correctly
if \(\text x\) \(\isin\) \(\text P\) Ā \(and\) Ā \(\sum_{i=0}^{n}\ w_i*x_iĀ < 0\) then
end
if \(\text x\) \(\isin\) \(\text N\)Ā \(and\) Ā \(\sum_{i=0}^{n}\ w_i*x_iĀ \geq 0\) then
\(\text w\) = \(\text w\)Ā \(-\) \(\text x\) ;
\(x_2\)
\(x_1\)
\(p_2\)
\(p_3\)
\(p_1\)
\(n_1\)
\(n_2\)
\(n_3\)
\(x_2\)
\(x_1\)
\(p_2\)
\(p_3\)
\(p_1\)
\(n_1\)
\(n_2\)
\(n_3\)
\(x_2\)
\(x_1\)
\(p_2\)
\(p_3\)
\(p_1\)
\(n_1\)
\(n_2\)
\(n_3\)
\(x_2\)
\(x_1\)
\(p_2\)
\(p_3\)
\(p_1\)
\(n_1\)
\(n_2\)
\(n_3\)
\(x_2\)
\(x_1\)
\(p_2\)
\(p_3\)
\(p_1\)
\(n_1\)
\(n_2\)
\(n_3\)
\(x_2\)
\(x_1\)
\(p_2\)
\(p_3\)
\(p_1\)
\(n_1\)
\(n_2\)
\(n_3\)
\(x_2\)
\(x_1\)
\(p_2\)
\(p_3\)
\(p_1\)
\(n_1\)
\(n_2\)
\(n_3\)
\(x_2\)
\(x_1\)
\(p_2\)
\(p_3\)
\(p_1\)
\(n_1\)
\(n_2\)
\(n_3\)
\(x_2\)
\(x_1\)
\(p_2\)
\(p_3\)
\(p_1\)
\(n_1\)
\(n_2\)
\(n_3\)
\(x_2\)
\(x_1\)
\(p_2\)
\(p_3\)
\(p_1\)
\(n_1\)
\(n_2\)
\(n_3\)
\(x_2\)
\(x_1\)
\(p_2\)
\(p_3\)
\(p_1\)
\(n_1\)
\(n_2\)
\(n_3\)
\(x_2\)
\(x_1\)
\(p_2\)
\(p_3\)
\(p_1\)
\(n_1\)
\(n_2\)
\(n_3\)
\(x_2\)
\(x_1\)
\(p_2\)
\(p_3\)
\(p_1\)
\(n_1\)
\(n_2\)
\(n_3\)
\(N \gets\) \(inputs\) \(with\) \(label\)Ā \(0\);
Initialize \(\text w\)Ā randomly;
while \(!convergence\)Ā do
Pick random \(\text p\)Ā \(\isin\) \( P'\)
\(\text w\) = \(\text w\)Ā \(+\) \(\text x\) ;
end
end
//the algorithm converges when all the inputs areĀ Ā Ā Ā Ā Ā Ā Ā Ā Ā Ā classified correctly
if \(\text x\) \(\isin\) \(\text P\) Ā \(and\) Ā \(\sum_{i=0}^{n}\ w_i*x_iĀ < 0\) then
\(N^-\) contains negations of all points in \(N\);
\(P' \gets P \cup N\)
\(p \gets\) \({p \over \parallelĀ p \parallel}\) (so now, \(\parallel p\parallel = 1)\)
Setup
//notice that we do not need the other if condition
Ā Ā because by construction we want all points in \(P'\) to lie
\(P \gets\) \(inputs\) \(with\) \(label\)Ā \(1\);
Proof:
Observations:
Proof (continued):
Proof (continued):
\(x_1\)
\(x_2\)
XOR
\(0\)
\(1\)
\(0\)
\(1\)
\(0\)
\(0\)
\(1\)
\(1\)
\(0\)
\(1\)
\(1\)
\(0\)
\(x_1\)
\(x_2\)
\(0\)
\(0\)
\(1\)
\(0\)
\(0\)
\(1\)
\(1\)
\(1\)
\(0\)
\(1\)
\(1\)
\(0\)
\(0\)
\(1\)
\(1\)
\(0\)
\(0\)
\(1\)
\(0\)
\(1\)
\(0\)
\(0\)
\(1\)
\(1\)
\(0\)
\(1\)
\(1\)
\(0\)
\(0\)
\(1\)
\(1\)
\(0\)
\(0\)
\(1\)
\(0\)
\(1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