Top Banner
CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay
32

CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Dec 26, 2015

Download

Documents

Stephen Hicks
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

CS623: Introduction to Computing with Neural Nets

(lecture-10)

Pushpak BhattacharyyaComputer Science and Engineering

DepartmentIIT Bombay

Page 2: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Tiling Algorithm (repeat)

• A kind of divide and conquer strategy• Given the classes in the data, run the

perceptron training algorithm• If linearly separable, convergence without

any hidden layer• If not, do as well as you can (pocket

algorithm)• This will produce classes with

misclassified points

Page 3: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Tiling Algorithm (contd)

• Take the class with misclassified points and break into subclasses which contain no outliers

• Run PTA again after recruiting the required number of perceptrons

• Do this until homogenous classes are obtained• Apply the same procedure for the first hidden

layer to obtain the second hidden layer and so on

Page 4: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Illustration

• XOR problem

• Classes are

(0, 0)

(1, 1)(0, 1)

(1, 0)

Page 5: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

As best a classification as possible

(0,0) (1,0)

(0,1) (1,1)+ve

+ve

-ve

-ve

Page 6: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Classes with error

(0,0)

(1,1)

(0,1)

(1,0)

outlier

Page 7: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

How to achieve this classification

• Give the labels as shown: eqv to an OR problem

(0,0) (1,1)

(0,1)

(1,0)

outlier

+-

Page 8: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

The partially developed n/w

• Get the first neuron in the hidden layer, which computes OR

x1x2

h1

0.5

1.01.0

Page 9: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Break the incorrect class

(1,1)

(0,1)

(1,0)

outlier

(1,0)(0,1)

(1,1)

(0,0)

+

-

Don’t care:Make +

Page 10: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Solve classification for h2

(1,1)

(1,0)

(0,1)

(0,0)

+

-

This is x1x2

Page 11: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Next stage of the n/w

x1x2

h1h2 0.5

1.01.0

-1.0 -1.0

-1.5

Computes x1x2 Computes x1+x2

Page 12: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Getting the output layer

• Solve a tiling algo problem for the hidden layer

x2 x1 h1

(x1+x2)

h1

x1x2

y

0 0 0 1 0

0 1 1 1 1

1 0 1 1 1

1 1 1 0 0

(1,1)(0,0)

(0,1)

(1,0)

+-

AND problem

Page 13: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Final n/w

x1x2

h1h2 0.5

1.01.0

-1.0 -1.0

-1.5

Computes x1x2 Computes x1+x2

• AND n/w

1.0 1.0

0.5

y

Computes x1x2

Page 14: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Lab exercise

Implement the tiling algorithm and run it for

1. XOR

2. Majority

3. IRIS data

Page 15: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Hopfield net• Inspired by associative memory which means

memory retrieval is not by address, but by part of the data.

• Consists of

N neurons fully connected with

symmetric weight strength wij = wji

• No self connection. So the weight matrix is 0-diagonal and symmetric.

• Each computing element or neuron is a linear threshold element with threshold = 0.

Page 16: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Computation

Page 17: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Example

w12 = w21 = 5

w13 = w31 = 3

w23 = w32 = 2

At time t=0

s1(t) = 1

s2(t) = -1

s3(t) = 1

Unstable state: Neuron 1 will flip.

A stable pattern is called an

attractor for the net.

Page 18: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Stability

• Asynchronous mode of operation: at any instant a randomly selected neuron compares the net input with the threshold.

• In the synchronous mode of operation all neurons update themselves simultaneously at any instant of time.

• Since there are feedback connections in the Hopfield Net the question of stability arises. At every time instant the network evolves and finally settles into a stable state.

• How does the Hopfield Net function as associative memory ?

• One needs to store or stabilize a vector which is the memory element.

Page 19: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Energy consideration

• Stable patterns correspond to minimum energy states.

• Energy at state <x1, x2, x3, …, xn>

• E = -1/2∑j∑j<>iwjixixj

• Change in energy always comes out to be negative in the asynchronous mode of operation. Energy always decreases.

• Stability ensured.

Page 20: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Hopfield Net is a fully connected network

n

1

2

3

4

. . . .

• ith neuron is connected to (n-1) neurons

Page 21: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Concept of Energy

• Energy at state s is given by the equation:

nn xxwxxwxxwsE 1131132112)(

nn xxwxxw 223223

nnnn xxw )1()1(

Page 22: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Connection matrix of the network, 0-diagonal and symmetric

n1 n2 n3 . . . nk

n1

n2

n3 . ..

nk

j

i wij

0 – diagonal

Page 23: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

State Vector

• Binary valued vector: value is either 1 or -1

X = <xn xn-1 . . . . x3 x2 x1>

• e.g. Various attributes of a student can be represented by a state vector

x1

x2

x3

x5

x4hair color Ram = 1

~(Ram) = -1

heightaddress

roll number

Page 24: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Relation between weight vector W and state vector X

W TX

Weight vector Transpose of state vector

3

21

2

5

3

1

-11

023

205

350

1

1

1

W TX

023

205

350

W

1

1

1

TX

For example, in figure 1,At time t = 0, state of the neural network is:s(0) = <1, -1, 1> and corresponding vectors are as shown.

Fig. 1

Page 25: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

W.XT gives the inputs to the neurons at the next time instant

023

205

350

1

1

1

W TX

1

7

2

1

1

1

).sgn( TXWThis shows that the n/w will change state

Page 26: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Energy Consideration

• E(0) = -[(5*1*-1)+(3*1* 1)+(2*-1*1)] = 4

3

21

2

5

3

1

-11

At time t = 0, state of the neural network is:s(0) = <1, -1, 1>

3

21

2

5

3

-1

-1-1

The state of the neural network under stability is <-1, -1, -1>

E(stable state) = - -[(5*-1*-1)+(3*-1* -1)+(2*-1*-1)] = -10

Page 27: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

State Change

• s(0) = <1, -1, 1…>• s(1) = compute by comparing and summing

• x1(t=1)=sgn[Σj=2nw1jxj]

= 1 if Σj=2nw1jxj > 0

= -1 otherwise

Page 28: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Theorem

• In the asynchronous mode of operation, the energy of the Hopfield net always decreases.

• Proof:

)()()()()()()( 11111311131211121 txtxwtxtxwtxtxwtE nn

)()()()( 1122131223 txtxwtxtxw nn

)()( 11)1()1( txtxw nnnn

Page 29: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Proof

• Let neuron 1 change state by summing and comparing• We get following equation for energy

)()()()()()()( 22112321132221122 txtxwtxtxwtxtxwtE nn

)()()()( 2222232223 txtxwtxtxw nn

)()( 22)1()1( txtxw nnnn

Page 30: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Proof: note that only neuron 1 changes state

)()()()()()( 1111131113121112 txtxwtxtxwtxtxw nn

n

j

jjj txtxtxtxw2

1112211 )()()()(

)()()()()()( 2211232113222112 txtxwtxtxwtxtxw nn

)()( 12 tEtEE

n

j

jj txtxtxw2

211111 )()()(

Since only neuron 1 changes state, xj(t1)=xj(t2), j=2, 3, 4, …n, and hence

Page 31: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

Proof (continued)

• Observations:– When the state changes from -1 to 1, (S) has to be +ve and

(D) is –ve; so ΔE becomes negative.– When the state changes from 1 to -1, (S) has to be -ve and

(D) is +ve; so ΔE becomes negative.

• Therefore, Energy for any state change always decreases.

n

j

jj txtxtxw2

211111 )()()(

(D)(S)

Page 32: CS623: Introduction to Computing with Neural Nets (lecture-10) Pushpak Bhattacharyya Computer Science and Engineering Department IIT Bombay.

The Hopfield net has to “converge” in the asynchronous mode of

operation• As the energy E goes on decreasing, it

has to hit the bottom, since the weight and the state vector have finite values.

• That is, the Hopfield Net has to converge to an energy minimum.

• Hence the Hopfield Net reaches stability.