Adl 1,2,3
Adl 1,2,3
Aim:
Implement multilayer perceptron algorithm for MNIST Hand written Digit Classification
Theory:
A Perceptron is the simplest form of an artificial neural network and is a fundamental unit
in machine learning. It consists of:
• Input layer: Accepts multiple input values.
• Weights: Each input is multiplied by a weight.
• Summation Function: Computes the weighted sum of inputs.
• Activation Function: Applies a threshold (e.g., step function, sigmoid, ReLU) to
determine the output.
The perceptron can only handle linearly separable data. To overcome this limitation, a
Multilayer Perceptron (MLP) is used. MLP consists many hidden layers which contains
neurons with activation functions (like ReLU) that help capture complex patterns.
MLPs are trained using backpropagation, which updates weights through gradient descent,
reducing the error over multiple iterations.
Algorithm:
The steps for training an MLP using backpropagation:
Step 1: Initialization
• Initialize weights and biases randomly.
• Set the number of layers and neurons.
Step 2: Forward Propagation
• Compute the weighted sum for each neuron: Z=W⋅X+BZ = W \cdot X + BZ=W⋅X+B
• Apply an activation function (e.g., ReLU or Sigmoid) to introduce non-linearity.
Step 3: Compute Loss
• Calculate the error using a loss function such as categorical cross-entropy for
classification.
Step 4: Backpropagation
• Compute the gradient of the loss with respect to weights and biases.
• Use chain rule to propagate errors backward through layers.
Step 5: Weight Update
• Adjust the weights using an optimizer like Adam or SGD.
Step 6: Repeat Until Convergence
• Repeat forward propagation and backpropagation for multiple epochs until the model
reaches a satisfactory accuracy.
Dataset:
The MNIST (Modified National Institute of Standards and Technology) dataset is a large collection of
handwritten digits widely used in machine learning. It consists of:
This dataset is ideal for testing image classification models and deep learning techniques because of its
simplicity and structured nature.
Code:
Learning Outcome:
Experiment 2
Aim:
Design a neural network for classifying movie reviews (Binary Classification) using IMDB
dataset.
Theory:
Binary classification is a type of supervised learning where a model predicts one of two
possible outcomes, such as Positive vs. Negative, Spam vs. Not Spam
Algorithm:
Step 1: Data Preprocessing
Dataset:
The IMDB (Internet Movie Database) dataset is a well-known dataset for sentiment
analysis of movie reviews. It includes:
Code:
Learning Outcome :
Experiment 3
Aim:
Design a neural Network for classifying news wires (Multi class classification) using Reuters
dataset.
Theory:
Multi-class classification is a type of supervised learning where a model assigns an input to
one of several predefined categories. Unlike binary classification, which has only two
possible outputs, multi-class classification deals with three or more classes.
A Neural Network (NN) for multi-class classification consists of:
1. Input Layer: Takes in numerical input data (in this case, word sequences).
2. Embedding Layer: Converts words into dense vector representations.
3. Hidden Layers: Extract features and patterns using neurons with activation functions
like ReLU.
4. Output Layer: Uses softmax activation to output probabilities for each class.
5. Loss Function: Categorical Cross-Entropy (CCE) is used to measure the difference
between predicted and actual class probabilities.
6. Optimizer: The Adam optimizer is used for efficient weight updates.
Algorithm:
Step 1: Data Preprocessing
Dataset:
The Reuters dataset is a widely used benchmark for multi-class text classification. It
consists of:
1. 11,228 news articles categorized into 46 different topics.
2. Each article is labeled with a category (business, politics, tech, etc.).
3. The dataset is preprocessed so that:
o Each word is assigned a unique index.
o Articles are stored as sequences of word indices.
o The data can be directly used for training neural networks.
Code:
Learning Outcome: