---
title: "Hebbian learning; AND function"
subject: "Artificial Intelligence"
chapter: 6
key: "semester_6/artificial_intelligence:hebbian-learning-and-network"
source: https://www.bctengineer.com/q/semester_6/artificial_intelligence/hebbian-learning-and-network
site: BCT Engineering
---

# Hebbian learning; AND function

Artificial Intelligence · Chapter 6: Machine Learning

- Asked in: 2073 Bhadra, 3+7 marks
- Video: [7. Design a Hebb net to implement logical AND function Soft Computing Machine Learning Mahesh Huddar](https://www.youtube.com/watch?v=YVVnBauo7yY) — Mahesh Huddar
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/artificial_intelligence/hebbian-learning-and-network
- Whole chapter: https://www.bctengineer.com/md/semester_6/artificial_intelligence/chapter-6

## Question

Define Hebbian learning. Use Hebbian learning algorithm to construct a Hebbian Network which performs like AND function.

## Short answer

Hebbian learning updates weights by Δw_i = x_i * y, strengthening connections between simultaneously active neurons. For an AND function with bipolar inputs, after processing all patterns, final weights are w1=2, w2=2, bias b=-2.

## Answer

#### Hebbian learning
**Hebbian learning** (Donald Hebb, 1949) is an unsupervised-style rule stating "neurons that fire together wire together": the weight between two neurons is strengthened when both are active together.

Rule: Δw_i = x_i · y (for supervised Hebb nets, y = target t), Δb = y; w_i(new) = w_i(old) + x_i·y.

#### Hebb net for the AND function
Use bipolar inputs and targets (1 = true, −1 = false). Initial w1 = w2 = b = 0.

| x1 | x2 | t | Δw1 = x1·t | Δw2 = x2·t | Δb = t | w1 | w2 | b |
|---|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| 1 | −1 | −1 | −1 | 1 | −1 | 0 | 2 | 0 |
| −1 | 1 | −1 | 1 | −1 | −1 | 1 | 1 | −1 |
| −1 | −1 | −1 | 1 | 1 | −1 | 2 | 2 | −2 |

Final weights: **w1 = 2, w2 = 2, b = −2**.

#### Testing: net = 2x1 + 2x2 − 2, output = +1 if net > 0, else −1
| x1 | x2 | net | output | target |
|---|---|---|---|---|
| 1 | 1 | 2 | 1 | 1 |
| 1 | −1 | −2 | −1 | −1 |
| −1 | 1 | −2 | −1 | −1 |
| −1 | −1 | −6 | −1 | −1 |

All outputs match, so the net has learned AND.

```text
 x1 --(2)-->\
             ( Σ + b ) --> sign --> y
 x2 --(2)-->/     ^ b = -2
```
Decision line: 2x1 + 2x2 − 2 = 0, i.e. x1 + x2 = 1.

## Check yourself

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

1. What does the Hebbian rule state?
   A. Weights change in proportion to the output error only
   B. Weights are fixed forever
   C. The winner takes all
   D. Neurons that fire together wire together; w_i(new) = w_i(old) + x_i y
   Answer: D. Weights are strengthened when both neurons are active. (Key point: Hebb rule)

2. What are the final Hebb net weights for bipolar AND?
   A. w1 = 2, w2 = 2, b = -2
   B. w1 = 1, w2 = 1, b = 1
   C. w1 = 2, w2 = 2, b = 2
   D. w1 = 0, w2 = 0, b = -2
   Answer: A. Summing Delta w = x*t and Delta b = t over the four patterns gives (2, 2, -2). (Key point: Final AND weights)

3. With w=(2,2), b=-2, what is the output for (1,-1)?
   A. net = 2, so output +1
   B. net = -2, so output -1
   C. net = 0, so output +1
   D. net = -6, so output +1
   Answer: B. 2 - 2 - 2 = -2, matching AND. (Key point: Test (1,-1))

4. Why use bipolar inputs and targets in this Hebb net?
   A. Bipolar values make the net faster only
   B. Hebb nets cannot take binary 1
   C. With 0 values the weights would not change and the false cases could not be learned
   D. To avoid using a bias
   Answer: C. A zero input or target gives no weight update. (Key point: Inputs used)

## Related in Artificial Intelligence

- [Machine learning, GA, operators, areas](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Aml-genetic-algorithm-operators-areas) — Artificial Intelligence, chapter 6, asked 2×
- [GA vs fuzzy based learning](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Aga-vs-fuzzy-learning) — Artificial Intelligence, chapter 6
- [Machine learning; Boltzmann machines](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Aml-boltzmann-machine) — Artificial Intelligence, chapter 6
- [Neural network; back-propagation](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Aneural-network-bp-algorithm) — Artificial Intelligence, chapter 6
- [Back propagation algorithm](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Aback-propagation-algorithm) — Artificial Intelligence, chapter 6, asked 3×
- [Neural network; supervised vs unsupervised](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Ann-supervised-unsupervised) — Artificial Intelligence, chapter 6

## Related in other subjects

- [Mapping function and replacement algorithm](https://www.bctengineer.com/question.md?key=semester_5%2Fcomputer_organization_and_architecture%3Amapping-replacement) — Computer Organization and Architecture, chapter 6
- [Voltage ratio transfer function of two-section LC network](https://www.bctengineer.com/question.md?key=semester_3%2Felectrical_circuit_theory%3Avoltage-ratio-tf-two-1h-shunt) — Electrical Circuit Theory, chapter 5
- [Poles and zeros of a network function](https://www.bctengineer.com/question.md?key=semester_3%2Felectrical_circuit_theory%3Apoles-and-zeros-significance) — Electrical Circuit Theory, chapter 5
- [Short note: Neural network, perceptron rule](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aneural-network-perceptron-note) — Data Mining, chapter 3
