Skip to content
doubtly

2 answers

Hebb Net to Implement OR Function

Introduction:

A Hebb net is a type of artificial neural network that can be used to implement simple logical functions. In this example, we will design a Hebb net to implement the OR function using bipolar inputs and targets.

Bipolar Inputs and Targets:

Bipolar inputs and targets take on values of -1 and 1, respectively. For the OR function, the truth table is as follows:

Input 1 Input 2 Target
-1 -1 -1
-1 1 1
1 -1 1
1 1 1

Hebb Net Architecture:

A Hebb net consists of a layer of input neurons and a layer of output neurons. The input neurons are connected to the output neurons with weighted connections. The weights are updated based on the Hebb learning rule.

Hebb Learning Rule:

The Hebb learning rule states that the weight between two neurons is increased if the neurons are both active (i.e., have a value of 1) and decreased if the neurons are both inactive (i.e., have a value of -1).

Design:

To design a Hebb net to implement the OR function, we need to set the weights between the input neurons and the output neuron as follows:

  • w1 = 1
  • w2 = 1
  • θ = -1

Operation:

When the input neurons are activated with bipolar inputs, the output neuron will calculate the weighted sum of the inputs and compare it to the threshold θ. If the weighted sum is greater than or equal to θ, the output neuron will be activated and output a value of 1. Otherwise, the output neuron will be inactive and output a value of -1.

Example:

Let’s consider the input pattern (-1, 1). The weighted sum of the inputs is:

w1 * Input 1 + w2 * Input 2 = 1 * (-1) + 1 * 1 = 0

Since the weighted sum is less than the threshold θ, the output neuron will be inactive and output a value of -1. This matches the target value for the OR function.

Doubtly · 31 Mar 2024 Report

Training with the Hebb rule from zero weights gives \(w_1 = 2,\ w_2 = 2,\ b = 2\), and this net reproduces the bipolar OR function.

Hebb rule: \(w_i(\text{new}) = w_i(\text{old}) + x_i t\), \(b(\text{new}) = b(\text{old}) + t\). Start with \(w_1 = w_2 = b = 0\).

\(x_1\)\(x_2\)\(t\)\(\Delta w_1\)\(\Delta w_2\)\(\Delta b\)\(w_1\)\(w_2\)\(b\)
111111111
1−111−11202
−111−111113
−1−1−111−1222

Final net: \(y_{in} = 2 + 2x_1 + 2x_2\), output \(y = 1\) if \(y_{in} \ge 0\), else \(-1\).

Check:

  • (1, 1): \(2 + 2 + 2 = 6\), so \(y = 1\)
  • (1, −1): \(2 + 2 - 2 = 2\), so \(y = 1\)
  • (−1, 1): \(2 - 2 + 2 = 2\), so \(y = 1\)
  • (−1, −1): \(2 - 2 - 2 = -2\), so \(y = -1\)

All four outputs match the OR targets. The decision line is \(2 + 2x_1 + 2x_2 = 0\), i.e. \(x_2 = -x_1 - 1\), which separates (−1, −1) from the other three points.

Tutor AI · 23 Oct 2026 AI-verified AI-generated Report

Your answer

Log in or create a free account to answer this question.