0% found this document useful (0 votes)
12 views9 pages

Adl 1,2,3

The document outlines three experiments involving neural networks for different classification tasks: MNIST digit classification using a multilayer perceptron, binary classification of movie reviews using the IMDB dataset, and multi-class classification of news articles using the Reuters dataset. Each experiment includes a theoretical background, algorithm steps, and dataset descriptions. The document emphasizes the importance of neural network architecture, activation functions, loss functions, and optimizers in training models for these tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views9 pages

Adl 1,2,3

The document outlines three experiments involving neural networks for different classification tasks: MNIST digit classification using a multilayer perceptron, binary classification of movie reviews using the IMDB dataset, and multi-class classification of news articles using the Reuters dataset. Each experiment includes a theoretical background, algorithm steps, and dataset descriptions. The document emphasizes the importance of neural network architecture, activation functions, loss functions, and optimizers in training models for these tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

Experiment 1

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:

• 60,000 training images and 10,000 test images.


• Each image is 28×28 pixels, grayscale (0-255 pixel intensity).
• Contains 10 digit classes (0-9).

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

A Neural Network (NN) for binary classification consists of:

1. Input Layer: Takes in numerical input data.


2. Hidden Layers: Extract features and patterns using neurons and activation functions
like ReLU.
3. Output Layer: Uses a single neuron with a sigmoid activation function to output a
probability between 0 and 1.
4. Loss Function: Binary Cross-Entropy (BCE) is used to measure the difference
between predicted and actual labels.
5. Optimizer: The Adam optimizer helps minimize loss using backpropagation and
gradient descent.

Algorithm:
Step 1: Data Preprocessing

• Load the dataset (e.g., IMDB movie reviews).


• Convert text to numerical data (word index representation).
• Pad sequences to a uniform length.

Step 2: Build the Neural Network

• Add an Embedding Layer to represent words as dense vectors.


• Use a GlobalAveragePooling1D Layer to reduce dimensionality.
• Add Dense Layers for feature extraction with ReLU activation.
• Add an Output Layer with sigmoid activation.

Step 3: Compile the Model

• Use binary cross-entropy as the loss function.


• Choose Adam optimizer to adjust weights.
Step 4: Train the Model

• Fit the model using training data with multiple epochs.


• Use a validation set to monitor performance.

Step 5: Evaluate the Model

• Test the model on unseen data.


• Calculate accuracy and loss.

Dataset:
The IMDB (Internet Movie Database) dataset is a well-known dataset for sentiment
analysis of movie reviews. It includes:

1. 50,000 reviews (25,000 for training, 25,000 for testing).


2. Binary labels:
o 0 → Negative review
o 1 → Positive review
3. Preprocessed Text Data:
o Each word is mapped to an integer based on frequency.
o Reviews are converted into sequences of integers.

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

• Load the Reuters news wire dataset.


• Convert text into numerical sequences.
• Pad sequences to ensure uniform input size.
• Convert class labels into one-hot encoding for multi-class classification.

Step 2: Build the Neural Network

• Add an Embedding Layer to represent words as dense vectors.


• Use a GlobalAveragePooling1D Layer to reduce dimensionality.
• Add Dense Layers with ReLU activation to learn patterns.
• Add an Output Layer with softmax activation.

Step 3: Compile the Model


• Use categorical cross-entropy as the loss function.
• Choose Adam optimizer to optimize weights.

Step 4: Train the Model

• Train the model using the training dataset.


• Use a validation set to track performance.

Step 5: Evaluate the Model

• Test the model on unseen data.


• Measure accuracy and loss.

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:

You might also like