---
title: "Hopfield network and its steps"
subject: "Artificial Intelligence"
chapter: 6
key: "semester_6/artificial_intelligence:hopfield-network-steps"
source: https://www.bctengineer.com/q/semester_6/artificial_intelligence/hopfield-network-steps
site: BCT Engineering
---

# Hopfield network and its steps

Artificial Intelligence · Chapter 6: Machine Learning

- Asked in: 2069 Bhadra, 8 marks
- Video: [Hopfield network-working with example.](https://www.youtube.com/watch?v=-GStNTZFzSY) — AI world with AR
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/artificial_intelligence/hopfield-network-steps
- Whole chapter: https://www.bctengineer.com/md/semester_6/artificial_intelligence/chapter-6

## Question

What is a Hopfield Network? Explain all the steps involved in the Hopfield Network with suitable example.

## Short answer

A Hopfield network is a recurrent auto-associative memory with symmetric weights and no self-connections. Training stores bipolar patterns via Hebbian rule (W = Σ pᵀp, zero diagonal). Recall initializes with noisy input, updates neurons asynchronously (x_i = +1 if net>0, -1 if net<0) until stable; energy always decreases. Example: storing [1,-1,1,-1] and recalling from [1,1,1,-1] corrects the second bit to -1.

## Answer

A **Hopfield network** (John Hopfield, 1982) is a single-layer, fully connected **recurrent** network that works as an auto-associative (content-addressable) memory. Each neuron is connected to every other neuron with **symmetric weights** (wij = wji) and **no self-connection** (wii = 0). Neurons take binary or bipolar states (+1 / −1). Given a noisy or partial pattern it settles to the nearest stored pattern.

```text
   (1)---(2)
    | \ / |
    | / \ |
   (4)---(3)     every neuron connected to all others
```

#### Steps
**Training (storing patterns)**
1. Choose bipolar patterns p to store.
2. Compute weights by the Hebbian outer-product rule: W = Σ pᵀp, and set the diagonal to 0 (wij = Σ p_i p_j, i ≠ j).

**Recall (testing)**
3. Initialise the network state x with the input (noisy) pattern.
4. Pick a neuron i at random (asynchronous update) and compute net_i = Σ_j w_ij x_j (plus any external input).
5. Update: x_i = +1 if net_i > 0, −1 if net_i < 0, unchanged if net_i = 0.
6. Repeat steps 4-5 until no neuron changes (stable state). The network always converges because the energy E = −½ Σ Σ w_ij x_i x_j never increases.

#### Example (verified)
Store p = [1, −1, 1, −1]. Weights wij = pi·pj for i ≠ j:
```text
      n1  n2  n3  n4
 n1 [  0  -1   1  -1 ]
 n2 [ -1   0  -1   1 ]
 n3 [  1  -1   0  -1 ]
 n4 [ -1   1  -1   0 ]
```
Test with noisy input x = [1, 1, 1, −1] (second bit wrong):
- n1: net = 0·1 + (−1)(1) + 1·1 + (−1)(−1) = 1, so x1 = +1 (no change)
- n2: net = (−1)(1) + 0 + (−1)(1) + 1·(−1) = −3, so x2 = −1 (corrected)
- n3: net = 3 → +1; n4: net = −3 → −1

The state becomes [1, −1, 1, −1], the stored pattern, and stays stable on another sweep.

**Limits:** capacity is only about 0.15 N patterns for N neurons, and it may settle in spurious local minima.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Which property describes a Hopfield network?
   A. Single layer, fully connected recurrent, with symmetric weights and no self-connections
   B. Multilayer feed-forward with asymmetric weights
   C. Fully connected with self-connections wii = 1
   D. Two-layer competitive network with winner-takes-all
   Answer: A. wij = wji and wii = 0; it works as an auto-associative memory. (Key point: Hopfield structure)

2. How are Hopfield weights computed for storing patterns?
   A. By back-propagation of errors
   B. By the Hebbian outer-product rule W = sum of pT p with diagonal set to 0
   C. By repeated random updates until stable
   D. By the winner-takes-all rule
   Answer: B. Weights are computed once from the stored patterns. (Key point: Weight computation)

3. In recall, what is the update for neuron i?
   A. x_i = net_i without thresholding
   B. x_i = +1 always if any neighbour is +1
   C. x_i = +1 if net_i > 0, -1 if net_i < 0, unchanged if net_i = 0
   D. x_i is reset to 0 each step
   Answer: C. net_i = sum w_ij x_j is thresholded to give a bipolar state. (Key point: Update rule)

4. Why does the Hopfield network converge to a stable state?
   A. Because the weights are changed during recall
   B. Because the number of neurons is small
   C. Because the learning rate is reduced
   D. Asynchronous updates never increase the energy E = -1/2 sum w_ij x_i x_j
   Answer: D. Energy never rises, so the state settles in a minimum (possibly spurious). (Key point: Convergence)

## Related in Artificial Intelligence

- [Hopfield vs Kohonen network](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Ahopfield-vs-kohonen) — Artificial Intelligence, chapter 6
- [Self-organizing map (SOM) steps](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Aself-organizing-map) — Artificial Intelligence, chapter 6
- [NLU and NLG; NLP steps](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Anlu-nlg-nlp-steps) — Artificial Intelligence, chapter 7

## Related in other subjects

- [Steps in realizing transmission zeros](https://www.bctengineer.com/question.md?key=semester_5%2Ffilter_design%3Atransmission-zeros-realization-steps) — Filter Design, chapter 4, asked 2×
- [Define simulation; steps of simulation study](https://www.bctengineer.com/question.md?key=semester_8%2Fsimulation_and_modeling%3Asimulation-study-steps) — Simulation and Modeling, chapter 1, asked 5×
- [Steps of photolithography process](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Aphotolithography-steps) — Embedded System, chapter 8, asked 4×
- [Steps of virtual (unit) load method](https://www.bctengineer.com/question.md?key=semester_4%2Ftheory_of_structures_i%3Aunit-load-method-steps) — Theory of Structures I, chapter 3, asked 4×
