Artificial Neural Network (ANN)
Practical Assignment 1: Perceptron Algorithm
Subject: Artificial Neural Network
Faculty: Dr. Kiran P. Kamble
Assignment: Practical Assignment 1
1. Aim
To study and implement the Perceptron Algorithm for binary classification using Artificial
Neural Networks.
2. Theory
The Perceptron is one of the simplest types of artificial neural networks. It is a supervised
learning algorithm used for binary classification problems. The perceptron takes multiple
inputs, applies weights, sums them, and passes the result through an activation function
(usually a step function) to produce an output.
Mathematical Model:
Output = 1 if (w■x■ + w■x■ + ... + w■x■ + b) ≥ 0
Output = 0 otherwise
Where:
x = input vector
w = weight vector
b = bias
3. Algorithm Steps
1. Initialize weights and bias with small values.
2. For each training example, calculate the weighted sum.
3. Apply activation function.
4. Calculate error = desired output − predicted output.
5. Update weights and bias.
6. Repeat until error becomes zero or maximum iterations reached.
4. Python Implementation
import numpy as np
X = [Link]([[0,0],[0,1],[1,0],[1,1]])
y = [Link]([0,0,0,1])
weights = [Link](2)
bias = 0
lr = 0.1
for epoch in range(10):
for i in range(len(X)):
net = [Link](X[i], weights) + bias
output = 1 if net >= 0 else 0
error = y[i] - output
weights += lr * error * X[i]
bias += lr * error
print('Weights:', weights)
print('Bias:', bias)
5. Result
The perceptron successfully classifies the binary input data after training. The weights and
bias are adjusted during training to minimize classification error.
6. Conclusion
The Perceptron Algorithm is a fundamental supervised learning algorithm in artificial
neural networks. It can solve linearly separable classification problems efficiently and
forms the basis for more advanced neural network models.