AND Gate using Perceptron

 

๐Ÿ”น AND Gate using Perceptron

1. ๐Ÿง  Problem Definition

The AND gate outputs 1 only when both inputs are 1.

Truth Table:

x₁    x₂    Output (y)
0    0    0
0    1    0
1    0    0
1    1    1

2. ⚙️ Perceptron Model

A perceptron computes:

y=step(w1x1+w2x2+b)y = \text{step}(w_1 x_1 + w_2 x_2 + b)

Where:

  • w1,w2w_1, w_2: weights
  • bb: bias
  • step(): activation function (0 or 1)

3. ๐Ÿ”ข Choosing Weights and Bias

To implement AND, we need:

  • Output = 1 only when both inputs are 1

A valid choice:

  • w1=1w_1 = 1
  • w2=1w_2 = 1
  • b=−1.5b = -1.5



4. ๐Ÿงฎ Verification

Let’s test all inputs:

Case 1: (0, 0)

1(0)+1(0)−1.5=−1.5⇒01(0) + 1(0) - 1.5 = -1.5 \Rightarrow 0

Case 2: (0, 1)

1(0)+1(1)−1.5=−0.5⇒01(0) + 1(1) - 1.5 = -0.5 \Rightarrow 0

Case 3: (1, 0)

1(1)+1(0)−1.5=−0.5⇒01(1) + 1(0) - 1.5 = -0.5 \Rightarrow 0

Case 4: (1, 1)

1(1)+1(1)−1.5=0.5⇒11(1) + 1(1) - 1.5 = 0.5 \Rightarrow 1

✅ Matches the AND truth table perfectly.


5. ๐Ÿ“ Geometric Interpretation

  • The perceptron creates a decision boundary (line):
x1+x2=1.5x_1 + x_2 = 1.5
  • Points:
    • (0,0), (0,1), (1,0) → below the line → class 0
    • (1,1) → above the line → class 1

➡️ This shows AND is linearly separable.





6. ๐ŸŽฏ Key Insight

The perceptron works for the AND gate because the data can be separated by a straight line.


๐Ÿ”น Summary

A single-layer perceptron implements an AND gate by choosing weights and bias such that only the input (1,1) produces an output above the threshold.

Comments

Popular posts from this blog

Machine Learning PCCST503 Semester5 KTU CS 2024 Scheme - Dr Binu V P

Introduction to Machine Learning (ML)

Distinguishing Machine Learning from Traditional Programming