cs623: introduction to computing with neural netscs623/pdf/cs623-lect13-21sept06.pdf · cs623:...

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

Upload: others

Post on 21-Mar-2020

18 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

CS623: Introduction to Computing with Neural Nets

(lecture-13)Pushpak Bhattacharyya

Computer Science and Engineering DepartmentIIT Bombay

Page 2: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Hopfield Net: an o(n2) algorithm• Consider the energy expression

M

1 2 1 2 1 3 1 3 1 1[ n nE w x x w x x w x x= − + + +K

2 3 2 3 2 4 2 4 2 2n nw x x w x x w x x+ + + +K

( 1 ) ( 1 ) ]n n n nw x x− −+

• E has [n(n-1)]/2 terms• Nature of each term

– wij is a real number– xi and xj are each +1 or -1

Page 3: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

No. of steps taken to reach stability

• Egap = Ehigh - Elow

Ehigh

Elow

Egap

Page 4: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Analysis of the weights and consequent Ehigh and Elow

• Wil is any weight with upper and lower bounds as Wmax and Wmin respectively. Suppose

wmin ≤ wij ≤ wmax

wmax > wmin

• Case 1: wmax > 0, wmin > 0Ehigh = (1/2) * wmax * n * (n-1)Elow = -(1/2) * wmax * n * (n-1)

Page 5: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Continuation of analysis of Ehigh and Elow

• Case 2: wmin < 0, wmax < 0Ehigh = (1/2) * wmin * n * (n-1)Elow = -(1/2) * wmin * n * (n-1)

• Case 3: wmax > 0, wmin < 0Ehigh = (1/2) * max(|wmax|,|wmin|) * n*(n-1)Elow = -(1/2) * max(|wmax|,|wmin|) * n*(n-1)

Page 6: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

The energy gap

• In general,

Ehigh

Elow

Egap = max(|wmax|, |wmin|) * n*(n-1)

Page 7: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

To find ΔEmin

ΔEp = (xpinitial - xp

final) * netpwhere ΔEp is the change in energy due to the pth neuron changing activation.

| ΔEp | = | (xpinitial - xp

final) * netp|= 2 * | netp|

where netp = Σnj=1, j≠p wpjxj

Page 8: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

To find ΔEmin

• [Σnj=1, j≠p wpjxj]min is determined by the precision of

the machine computing it.• For example, assuming 7 places after the

decimal point, the value cannot be lower than 0.0000001 [it can be 0, but that is not of concern to us, since the net will continue in the same state]

• Thus ΔEmin is a constant independent of n, determined by the precision of the machine.

Page 9: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Final observation: o(n2)

• It is possible to reach the minimum independent of n.

• Hence in the worst case, the number of steps taken to cover the energy gap is less than or equal to[max(|wmax|,|wmin|) * n * (n-1)] / constant

• Thus stability has to be attained in O(n2)steps

Page 10: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Hopfield Net for Optimization

• Optimization problem– Maximizes or minimizes a quantity

• Hopfield net used for optimization– Hopfield net and Traveling Salesman Problem– Hopfield net and Job Scheduling Problem

Page 11: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

The essential idea of the correspondence

• In optimization problems, we have to minimize a quantity.

• Hopfield net minimizes the energy• THIS IS THE CORRESPONDENCE

Page 12: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Hopfield net and Traveling Salesman problem

• We consider the problem for n=4 cities• In the given figure, nodes represent cities

and edges represent the paths between the cities with associated distance.

D C

A B

dDA dBC

dCD

dAB

dBDdAC

Page 13: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Traveling Salesman Problem

• Goal– Come back to the city A, visiting j = 2 to n (n is

number of cities) exactly once and minimize the total distance.

• To solve by Hopfield net we need to decide the architecture:– How many neurons?– What are the weights?

Page 14: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Constraints decide the parameters

1. For n cities and n positions, establish city to position correspondence, i.e.

Number of neurons = n cities * n positions2. Each position can take one and only one

city3. Each city can be in exactly one position4. Total distance should be minimum

Page 15: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Architecture• n * n matrix where

rows denote cities and columns denote positions

• cell(i, j) = 1 if and only if ith city is in jth position

• Each cell is a neuron• n2 neurons, O(n4)

connections

pos(α)

city(i)

Page 16: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Expressions corresponding to constraints

1. Each city in one and only one position i.e. a row has a single 1.

• Above equation partially ensures each row has a single 1

• xiα is I/O cost at the cell(i, α)

βα αββ

α i

n

i

n n

i xxAE ∑∑ ∑= = ≠=

=1 1 ,1

1 2

Page 17: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Expressions corresponding to constraints (contd.)

2. Each position has a single cityi.e. each column has at most single 1.

∑∑ ∑= = ≠=

⋅=n n

i

n

ijjji xxBE

1 1 ,12 2 α

αα

Page 18: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Expressions corresponding to constraints (contd.)

3. All cities MUST be visited once and only once

2

1 13 ])[(

2 ∑∑= =

−=n

i

n

i nxCEα

α

Page 19: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Expressions corresponding to constraints (contd.)

• E1, E2, E3 ensure that each row has exactly one 1 and each column has exactly one 1

• If we minimize E1 + E2 + E3

• Ensures a Hamiltonian circuit on the city graph which is an NP-complete problem.

Page 20: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Constraiant of distance

4. The distance traversed should be minimum

])([2 1 ,1

)1(,)1(,4 ∑ ∑= ≠=

−+ +⋅⋅=n

i

n

ijjjjiij xxxdDE ααα

dij = distance between city i and city j

Page 21: CS623: Introduction to Computing with Neural Netscs623/pdf/cs623-lect13-21sept06.pdf · CS623: Introduction to Computing with Neural Nets (lecture-13) Pushpak Bhattacharyya Computer

Expressions corresponding to constraints (contd.)

• We equate constraint energy:EProblem = Enetwork (*)

Where, Eproblem= E1+E2+E3+E4

and Enetwork is the well known energy expression for the Hopfield net

• Find the weights from (*).