CSC266 · 2081 · 5 marks
What is reinforcement learning? Configure an ANN neuron to simulate OR gate.
What is reinforcement learning? Configure an ANN neuron to simulate OR gate. [5]
Reinforcement Learning and ANN Neuron for OR Gate
Given
This is a conceptual + design question. The relevant "data" is:
- Task 1: Define reinforcement learning.
- Task 2: Configure a single ANN neuron (perceptron) to implement the OR logic function.
- OR gate truth table (standard, not given but implied):
| $x_1$ | $x_2$ | $y$ |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
No numeric parameters are supplied; the weights, bias, and threshold must be chosen by design.
Solution
Part 1: Reinforcement Learning
Reinforcement Learning (RL) is a machine learning paradigm in which an agent learns to make decisions by interacting with an environment through trial and error. The agent performs actions, observes the resulting state, and receives a reward (positive) or penalty (negative) as feedback. Its goal is to learn a policy (a mapping from states to actions) that maximizes the cumulative reward over time.
Key elements:
| Element | Meaning |
|---|---|
| Agent | The learner / decision maker |
| Environment | The world the agent interacts with |
| State | Current situation of the agent |
| Action | Choice made by the agent |
| Reward | Feedback signal (reinforcement) |
| Policy | Strategy for choosing actions |
There is no labelled training data as in supervised learning; instead learning is guided by the reward signal.
Types:
- Positive reinforcement - a favourable outcome strengthens and increases the frequency of a behaviour.
- Negative reinforcement - removing an unfavourable condition strengthens a behaviour.
Examples: game-playing agents (chess, Go), robot navigation, recommendation systems.
Part 2: ANN Neuron (Perceptron) for OR Gate
A single neuron computes a weighted sum plus bias, then applies a step activation function:
$$ \text{Net} = w_1 x_1 + w_2 x_2 + b $$
$$ y = \begin{cases} 1 & \text{if } \text{Net} \ge 0 \ 0 & \text{if } \text{Net} < 0 \end{cases} $$
Chosen parameters:
$$ w_1 = 1,\qquad w_2 = 1,\qquad b = -0.5 $$
This is equivalent to using weights $w_1 = w_2 = 1$ with a threshold $\theta = 0.5$ (since $\text{Net} \ge 0 \Leftrightarrow w_1x_1 + w_2x_2 \ge 0.5$).
Verification:
| $x_1$ | $x_2$ | $\text{Net}=x_1+x_2-0.5$ | $\text{Net}\ge 0$? | Output $y$ | Required |
|---|---|---|---|---|---|
| 0 | 0 | $-0.5$ | No | 0 | 0 ✓ |
| 0 | 1 | $0.5$ | Yes | 1 | 1 ✓ |
| 1 | 0 | $0.5$ | Yes | 1 | 1 ✓ |
| 1 | 1 | $1.5$ | Yes | 1 | 1 ✓ |
All four outputs match the OR truth table.
Neuron diagram:
w1 = 1
x1 ────────────┐
├──►[ Σ + b ]──► Step ──► y
x2 ────────────┘ (b = -0.5)
w2 = 1
Result: With $w_1 = w_2 = 1$ and bias $b = -0.5$ (threshold $\theta = 0.5$), a single perceptron correctly realizes the OR gate.
Common mistake: stating bias $b = 0$ together with threshold $\theta = 0.5$. These are inconsistent: $b = 0$ corresponds to $\theta = 0$, and the bias matching $\theta = 0.5$ is $b = -0.5$. Applying the $\theta = 0.5$ rule in the verification table still gives the correct logical behaviour and weights.
Short on time? The 1, 5 and 10 mark versions of this answer, flashcards and practice sets come with a program pass.