---
title: "Perceptron; neural network as OR gate"
subject: "Artificial Intelligence"
chapter: 6
key: "semester_6/artificial_intelligence:perceptron-or-gate"
source: https://www.bctengineer.com/q/semester_6/artificial_intelligence/perceptron-or-gate
site: BCT Engineering
---

# Perceptron; neural network as OR gate

Artificial Intelligence · Chapter 6: Machine Learning

- Asked in: 2072 Magh, 2+7 marks
- Video: [Lec-48: Understanding Single Layer Perceptron (SLP) with Example | Machine Learning](https://www.youtube.com/watch?v=rvxd13IHx1Y) — Gate Smashers
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/artificial_intelligence/perceptron-or-gate
- Whole chapter: https://www.bctengineer.com/md/semester_6/artificial_intelligence/chapter-6

## Question

What do you understand by a perceptron? How can we design a neural network that acts as an OR gate?

## Short answer

A perceptron is a single neuron that computes a weighted sum and outputs 1 if it exceeds a threshold. For an OR gate, set weights w1=w2=1 and threshold 0.5; net=x1+x2, output 1 if net >= 0.5.

## Answer

A **perceptron** is the simplest neural network: a single neuron that forms the weighted sum of its inputs, adds a bias (or compares with a threshold θ) and outputs 1 if the sum is large enough, else 0 (step function). It acts as a linear binary classifier and can learn with the rule w ← w + η(t − y)x.

#### Designing an OR gate
OR is linearly separable, so one perceptron is enough.

```text
 x1 --(w1 = 1)-->\
                  ( Σ ≥ θ ?)--> y      θ = 0.5  (or b = -0.5)
 x2 --(w2 = 1)-->/
```
Net input = 1·x1 + 1·x2; output y = 1 if net ≥ 0.5, else 0.

| x1 | x2 | net = x1 + x2 | y (net ≥ 0.5) | OR target |
|---|---|---|---|---|
| 0 | 0 | 0 | 0 | 0 |
| 0 | 1 | 1 | 1 | 1 |
| 1 | 0 | 1 | 1 | 1 |
| 1 | 1 | 2 | 1 | 1 |

All four rows match the OR truth table.

#### Check using inequalities
We need 0 < θ (for 0,0), w1 ≥ θ, w2 ≥ θ and w1 + w2 ≥ θ. Choosing w1 = w2 = 1, θ = 0.5 satisfies all of them.

#### Decision boundary
x1 + x2 = 0.5 is a line that separates (0,0) from the other three points.

#### Training alternative
Start with w1 = w2 = 0, b = 0, η = 1, use the output y = 1 if net > 0 (else 0), and apply the perceptron rule to the four patterns. It converges within three epochs to w = (1, 1), b = 0, which also implements OR (any weights that separate the classes will do).

**Answer: w1 = 1, w2 = 1, threshold 0.5.**

## Check yourself

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

1. Which weights and threshold implement OR with a perceptron?
   A. w1 = w2 = 1 and threshold 0.5
   B. w1 = w2 = 1 and threshold 2
   C. w1 = w2 = 0 and threshold 0.5
   D. w1 = 1, w2 = -1, threshold 1
   Answer: A. Net >= 0.5 fires for any input with at least one 1. (Key point: OR design)

2. For w1=w2=1, theta=0.5, what is the output for (1,1)?
   A. 0, since net = 2 is too large
   B. 1, since net = 2 >= 0.5
   C. 0, since both inputs are on
   D. Undefined
   Answer: B. OR gives 1 when any input is 1. (Key point: Check (1,1))

3. Why is a single perceptron enough for OR?
   A. OR is non-linear but small
   B. OR needs a hidden layer
   C. OR is linearly separable: a line separates (0,0) from the other three points
   D. Because OR has only one input
   Answer: C. The line x1 + x2 = 0.5 separates the classes. (Key point: Why one perceptron)

## Close variants set in other exams

- [Perceptron; neural network as XOR gate](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Aperceptron-xor-gate) — Artificial Intelligence, chapter 6, asked 2×

## Related in Artificial Intelligence

- [Role of perceptron in neural network](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Aperceptron-role) — Artificial Intelligence, chapter 6, asked 2×
- [Neural network, back-propagation, perceptron](https://www.bctengineer.com/question.md?key=semester_6%2Fartificial_intelligence%3Ann-bp-perceptron) — Artificial Intelligence, chapter 6

## Related in other subjects

- [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
