using a hopfield network: a nuts and bolts...

52
Using a Hopfield Network: A Nuts and Bolts Approach November 4, 2013 Gershon Wolfe, Ph.D.

Upload: others

Post on 14-Mar-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Using a Hopfield Network: A Nutsand Bolts Approach

November 4, 2013

Gershon Wolfe, Ph.D.

Page 2: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hopfield Model as Applied toClassification

● Hopfield network● Training the network● Updating nodes● Sequencing of node updates● When to stop updating● Examples● Cellular automation

Page 3: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hopfield Network

● A neural network in a highly interconnectedsystem of simple two-state elements

● Inspired by statistical mechanics

Networks with symmetric connections ≈ Equilibrium properties of magnetic systems

Hopfield showed that this equivalence can be used to design neural circuitsfor associative memory

Example: Spin glasses, magnetic systems with randomly distributed ferromagneticand antiferromagnetic interactions.

The spin glass phase (low temp phase) has long range interactionsthat create a rich topology with many local minima very close to the

Energy of the ground state. Neural systems share many propertieswith long range spin glasses.

Page 4: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hopfield Network

● Hopfield network (1980s) is a recurrent neuralnetwork (RNN) where connections betweenunits form a directed cycle– An RNN where all connections are symmetric

– This guarantees its dynamics will converge

● If trained using Hebbian learning, then Hopfieldnetwork. Then Hopfield can perform as a robustcontent-addressable memory, and resistant toconnection alterations

Page 5: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hebb Rule

● Introduced by Donald Hebb in 1949 in order toexplain associative memory.

● Hebb states that: Cell A need to take part infiring cell B, and can occur only if cell A firs justbefore, but not at the same time as, cell B

● From the point of view of artificial neuralnetworks, the Hebb rule can be describes asdetermining how to alter the weights betweenmodal neurons– Weights increase if two neurons act simultaneously

– Weights decrease if they act seperatly

Page 6: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hebb Rule

● Nodes that are both positive or both negativetend to have strong positive weights, nodesopposite in sign tend to have strong negativeweights

● Hebb learning: wij = x

i x

j

Wij = weight of connection between neuron i and neuron

X = inputs for the particular neuron

This is pattern learning where weights update after everytraining example.

Page 7: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hebb Rule

● In a Hopfield network, connections wij are set to

zero if i=j. With binary neurons, with activationsof 1 or 0, the connection is:– 1 of connected neurons have the same activation

for a pattern

Page 8: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Binary Neurons

● An artificial neuron is a mathematical functionmodeled after biological neurons

● An artificial neuron receives one or more inputs(dendrites) and sums then to produce an output(axon)

● The sums of each node are weighted● The sums are passed trough a linear function

known as a transfer function

Page 9: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Binary Neurons

● For a neuron with m+1 inputs with signals x0 –

x

m and weight w

0 – w

m the output of the kth

neuron is:

yk = φΣw

kjx

ij=0

m

The output, yk, of the transfer function, φ, is binary depending on

if the input meets a specific threshold, θ, where:

yk = 1 if θ ≥ 0

yk = 0 if θ < 0

Page 10: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hopfield Model

● Energy based model because property isderived from a global energy function

● The units of a Hopfield network are binary:– Example: 1 and -1

– Example: 1 and 0

● Every pair of units in the net have a connectionthat is described by a weight

– wij

Page 11: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hopfield Network

● John Hopfield realized that if the connectionsare symmetric, there is a global energy function– Each binary configuration, or assignment of binary

values to each neuron of the network, of thenetwork has an energy

● With the right energy function, the binarythreshold decision rule causes the network tosettle to a minimum of the energy function

● Keep applying this rule, the network will end upin an energy minimum

Page 12: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

The Energy Function

● The global energy is the sum of manycontributions, and each contribution dependson one connection weight, and the binary stateof two neurons. Low energy is good:

E = - ∑ sib

i - ∑ s

is

jw

ij

wij

≡ Symmetric connection strength between twoneurons

s ≡ Activities of the two connected neurons, theseare binary variables (1 or 0)

b ≡ Bias term that only involves state ofindividual units

i i<j

Page 13: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

The Energy Function

● This simple energy function makes it possiblefor each unit to compute locally how its stateeffects the global energy

● Define an energy gap as the differencebetween when I is off and on

Egap

= ΔEi = E(s

i = 0) – E(s

i = 1) = b

i + ∑s

jw

ij

This difference is what is being computed by the binarythreshold rule.

j

Page 14: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

The Energy Function

● Differentiate the energy equation wrt the state ifthe ith unit (a binary variable)

dEgap

= ΔEi = b

i + ∑s

jw

ij

One way to find an energy minimum is to start fromA random state and update units one at a time inrandom order. For each unit, save the lowest global energyof the two state. Independent of the state it was previouslyin. → The binary threshold decision rule.

dsi

Page 15: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Finding Energy Minimum

● Start with a random global state, use binarythreshold decision rule

1 0 0

01

4 3 4 4

-1 -1

-5

-Erandom

= 4 Look at all pairs that are on

Page 16: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Probing Random Units

● Start probing units at random, and ask whatstate should this unit be in given current state ofall the other units

1 0 0

?1

4 3 4 4

-1 -1

-5

E? = -5*(1) + 4*(0) + 4*(0) = -5

Since -5 < 0 → node is turned off ? → 0

Page 17: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Probing Random Units

● Choose another node

1 ? 0

01

4 3 4 4

-1 -1

-5

E? = -1*(1) + 3*(1) + 4*(0) = 2

Since -2 ≥ 0 → node is turned on ? → 1When on, the global energy changes → E

global = 6

Page 18: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Decisions Need to be Sequential

● If units make simultaneous decisions theenergy could go up

● With parallel updates you can get oscillationswith a period of 2

0 0+5

-100

+5

Bias of +5 and a weight between them of -100

Page 19: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hopfield Model

● Hopfield (1982) proposed thatmemories could be energyminima of a neural net withsymmetric weights

– The binary thresholddecision rule can take partialmemory and clean them upinto full memories

● The idea of memories asenergy minima was proposedby I.A. Richards in 1924

– Memories are like a largecrystal than can sit ondifferent faces

● Using energy minima torepresent memories gives acontent-addressable memory

– Am item can be accessedby just knowing part of itscontent

– Like reconstructing adinosaur from a few of itsbones

Page 20: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Storing Memories in a Hopfield Net

● If we use activities of 1 and -1,you can store a binary statevector by incrementing theweight between any two unitsby the product of their activities

● Not error driven, you are notcomparing what you would ofpredicted with what the rightanswer is and then makingsmall adjustments

● With states of 0 and 1 the rule isslightly more complicated

ΔWij = S

iS

j

ΔWij = 4(Si – 1/2)(S

j – 1/2)

Page 21: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hopfield Model

● A simple pattern that is meant to be recognizedby a Hopfield net

Input pattern

Trained-on pattern

Page 22: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hopfield Model

● Each pixel, or colored square, is one node inthe network

● You train, or assign weights, to multiplepatterns

● Given the input pattern, , theHopfield network iterates through the weightsand will reproduce this pattern

● The array of pixels could represent anything– 2D spectra, mosaic patterns, quasi-crystals,

topology, sound waves, etc.

Page 23: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hopfield Model

● Hamming distance: The number of positionsbetween two strings of equal length in which thecorresponding positions are different

Measuring the minimum number of substitutions required to change onestring into the other. In this example the Hamming distance is 2. The Levenshtein distance is a bit more sophisticated, and will handle strings of different lengths, and is related to pairwise string alignment..

Page 24: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hopfield Model

● Hamming distance: The number of positionsbetween two strings of equal length in which thecorresponding positions are different

Measuring the minimum number of substitutions required to change onestring into the other. In this example the Hamming distance is 2. The Levenshtein distance is a bit more sophisticated, and will handle strings of different lengths, and is related to pairwise string alignment..

Page 25: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Levenstein Distance

● Used in optical character recognition● Pattern recognition: Trained from labelled or

unlabeled data– Supervised learning: Analyze training data and

produce a function that can be used to map newexamples. Both inputs and outputs are provided.

– Unsupervised learning: Learn to represent particularinput patterns in a way that reflects the statisticalstructure of the overall collection. It must learnthese by itself.

Page 26: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hopfield Model

● Computational time: N pixels, N2 weights, – Can become computationally time demanding

Page 27: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Unsupervised Learning

● If there is no teacher, how do unsupervisednetworks learn?– Association of different bits of information

– Very useful for character recognition

Page 28: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hopfield Model

● All nodes in a Hopfiled network are both inputsand outputs, and fully interconnected.

● Links from each node to itself have a weight ofzero.

-2

-2

1

1

1

1

Page 29: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hopfield Network

● From previously slide, all nodes are input toeach other, and they are also outputs.

● How it works– Input a distorted pattern onto the nodes of the

network

– Iterate many times

– Eventually, the distorted pattern will be transformedonto on of the trained patterns

Page 30: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Hopfield Model

● What you need to know– How to train the network

– How to update a node in the network

– Sequencing of node update

– How to tell when you are at one of the trainedpatterns

Page 31: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Training

● Calculate values of weights, Wij

Suppose you want to store a set of states, VS

Where s = 1, …, n. The weights are calculatedAs follows:

Wij = Σ (2V Δ

i – 1)(2V Δ

j – 1)

Wij = 0 for i = j

For only one pattern:

Wij = (2V

i – 1)(2V

j – 1)

s=1

n

Page 32: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Training

● Example: A five node network and you want totrain it on the following pattern:

● Generate a matrix of 5x5 weights

0 W12 W13 W14 W15

W21 0 W23 W24 W25

W31 W32 0 W34 W35

W41 W42 W43 0 W45

W51 W52 W53 W54 0

Page 33: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Training

● The weights are symmetric

Wij = (2V

i – 1)(2V

j – 1) = (2V

j – 1)(2V

i – 1) = W

ji

Only have to calculate the upper diagonal, then copy eachof the weights into its inverse weight

If V = (0 1 1 0 1), then V1 = 0, V

2 = 1, V

3 = 1, V

4 = 0, V

5 = 1

Page 34: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Training

● Calculate weights for upper triangle

W12 = (2V1 - 1)(2V2 - 1) = (0 - 1)(2 - 1) = (-1)(1) = -1W13 = (2V1 - 1)(2V3 - 1) = (0 - 1)(2 - 1) = (-1)(1) = -1W14 = (2V1 - 1)(2V4 - 1) = (0 - 1)(0 - 1) = (-1)(-1) = 1W15 = (2V1 - 1)(2V5 - 1) = (0 - 1)(2 - 1) = (-1)(1) = -1W23 = (2V2 - 1)(2V3 - 1) = (2 - 1)(2 - 1) = (1)(1) = 1W24 = (2V2 - 1)(2V4 - 1) = (2 - 1)(0 - 1) = (1)(-1) = -1W25 = (2V2 - 1)(2V5 - 1) = (2 - 1)(2 - 1) = (1)(1) = 1W34 = (2V3 - 1)(2V4 - 1) = (2 - 1)(0 - 1) = (1)(-1) = -1W35 = (2V3 - 1)(2V5 - 1) = (2 - 1)(2 - 1) = (1)(1) = 1W45 = (2V4 - 1)(2V5 - 1) = (0 - 1)(2 - 1) = (-1)(1) = -1

Page 35: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Training

● Weight matrix

0 -1 -1 1 -1

-1 0 1 -1 1

-1 1 0 -1 1

1 -1 -1 0 -1

-1 1 1 -1 0

Page 36: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Training

● Remember that original formula was set up tohave n patterns– V1 = (0 1 1 0 1)

– V2 = (1 0 1 0 1)

Recall that the weights for n states are:

Wij = Σ (2V Δ

i – 1)(2V Δ

j – 1)

s=1

n

Page 37: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Training

● Calculate weights for the two sets

W12

= Σ (2V Δi – 1)(2V Δ

j – 1)

= (2V 11 – 1)(2 V 1

2 – 1) + (2V 2

1 – 1)(2V 2

2 – 1)

= (2* 0 – 1)(2* 1 – 1) + (2* 1 – 1)(2* 0 – 1)= (0 – 1)(2 – 1) + (2 – 1)(0 – 1)= (21)(1) + (1)(21)= 21 + 211= 22

Page 38: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Training

● The complete weight matrix for the two patterns

0 -2 0 0 0

-2 0 0 0 0

0 0 0 -2 2

0 0 -2 0 -2

0 0 2 -2 0

Page 39: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Updating Nodes

● The weight matrix is meant to recognize thepatterns:

Differ by 2 bits

Patterns this close together might be difficult to tell apart

Page 40: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Updating Nodes

● Use an input state of (1 1 1 1 1) or● For example, if node 3 is being updated:

– The values of all the other nodes are used as inputvalues, and the weights from those nodes to node 3as the weights

● Steps:– Do a weighted sum of inputs from other nodes

● Then if value is >= to 0, output a 1● Otherwise output a 0

Page 41: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Updating Nodes

● In formula form:

Viin = Σ W

jiV

j

Vi → 1 if V

iin ≥ 0

else Vi → 0

Page 42: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Updating Nodes

● Using the weight matrix from the previous slide

0 -2 0 0 0

-2 0 0 0 0

0 0 0 -2 2

0 0 -2 0 -2

0 0 2 -2 0

V3in = Σ W

j3V

j for j ≠ 3

= W13

V1 + W 2

3V

2 + W 4

3V

4 + W 5

3V

5

= 0* 1 + 0* 2 +22* 1 + 2* 1= 0 since 0 ≥ =, then V

3 = 1

Page 43: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Sequencing of Node Updates

● How do you update a neuron if the values of itsinputs are changing? There are two ways– Synchonous updating: All nodes are updated at the

same time. Just multiply the weight matrix by thevector of the current state. However, this is notrealistic in a neural sense, because neurons don'tupdate at the same rate. They have delays, firingtimes, etc... → More realistic is to update the nodesin random order. In fact, this is the methoddescribed by John Hopfield in 1982.

Page 44: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Sequencing of Node Updates

● Keep updating the neurons in a random manneruntil the system is in a stable state.

● An example of a sequence for node updatescould look like this: 3 2 1 5 4 2 3 1 5 4, etc...

Page 45: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

When to Stop Updating Network

● Simply put, if you go through all the nodes andnone of them change, then you can stop.

Page 46: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Finish the Example

● Given the weight matrix for a 5 node net with (01 1 0 1) and (1 0 1 0 1) as attractors, start atstate (1 1 1 1 1) and see where it goes.

● Update in sequence: 3 1 5 2 4 3 1 5 2 4, etc...We know from above that node 3 did notchange.

● The order of the sequence of updates has ahuge effect on classifying patterns that are verysimilar.

Page 47: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Finishing the Example

● Update node 1:

– V1in = (0 -2 0 0 0)*(1 1 1 1 1) = -2

● Since -2 < 0, V1 = 0 (changes)

● Update node 5:

– V5in = (0 0 2 -2 0)*(0 1 1 1 1) = 0

● Since 0 ≥ 0, V5 = 1 (does not change)

● Update node 2:

– V2in = (-2 0 0 0 0)*(0 1 1 1 1) = 0

● Since 0 ≥ 0, V2 = 1 (does not change)

Page 48: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Finishing the Example

● Update node 4:

– V1in = (0 0 -2 0 -2)*(0 1 1 1 1) = -4

● Since -4 < 0, V4 = 0 (changes)

● Update node 3:

– V3in = (0 0 0 -2 2)*(0 1 1 0 1) = 2

● Since 2 ≥ 0, V3 = 0 (does not change)

● Update node 1:

– V1in = (0 -2 0 0 0)*(0 1 1 0 1) = -2

● Since -2 < 0, V1 = 0 (does not change)

Page 49: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Finishing the Example

● Update node 5:

– V5in = (0 0 -2 2 0)*(0 1 1 0 1) = 2

● Since 2 ≥ 0, V5 = 1 (does not changes)

● Update node 2:

– V2in = (-2 0 0 0 0)*(0 1 1 0 1) = 0

● Since 0 ≥ 0, V2 = 1 (does not change)

● Update node 4:

– V4in = (0 0 -2 0 -2)*(0 1 1 0 1) = -4

● Since -4 < 0, V4 = 0 (does not change)

Page 50: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Finishing the Example

● Each node has been updated without anychange, so the iterations can stop and the statehas been classified.

● The network ends up at the attractor (0 1 1 0 1)● However, trying the exact same problem with a

different order for the updating sequence willclassify the state into the other attractor, (0 1 01 0)

Page 51: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Cellular Automation

● Can be used to propagate information onto atwo dimensional surface

● Any signal can be transformed into an array ofinformation using a rule based system– Using Rule 30 or Rule 110 to generate a fractal

image

– These images can be trained on using a Hopfieldnetwork and via unsupervised learning, candistinguish between states of a system.

– Systems can include: Drug discovery, up and downregulation, early detection of disease, micro-arraydata, etc...

Page 52: Using a Hopfield Network: A Nuts and Bolts Approachgershonwolfe.com/wordpress_6/wp-content/uploads/2015/09/Hopfield_Model... · Hopfield Network John Hopfield realized that if the

Summary

● Shown how the Hopfield model can be used toclassify data

● Gave examples● Integration of cellular automation to prepare

data sets for classification