LIST OF EXPERIMENTS:
1. Implement simple vector addition in Tensor Flow.
2. Implement a regression model in Keras.
3. Implement a perception in TensorFlow/Keras Environment.
4. Implement a Feed Forward Network in TensorFlow/Keras.
5. Implement an image classifier using CNN in TensorFlow/Keras.
6. Improve the deep Learning model by fine tuning hyper parameters.
7. Implement a Transfer Learning concept in image classification.
8. Using a pre trained model on Keras for transfer learning.
9. Perform Sentimental Analysis using RNN.
10. Implement an LSTM based Auto encoding inTensorflow/Keras.
11. Image generation using GAN.
ADDITIONAL EXPERIMENTS
12. Train a deep Learning model to classify a given image using pre trained model.
13. Recommendation system from sales data using Deep Learning.
14. Implement Object detection using CNN.
15. Implement any simple Reinforcement Algorithm for an NLP problem.
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
1. NEHRU INSTITUTE OF ENGINEERING AND TECHNOLOGY
(AUTONOMOUS)
Thirumalayampalayam, Coimbatore-641 105
(Approved by AICTE, New Delhi and Affiliated to Anna University, Chennai)
An ISO 9001:2015 and ISO 14001:2015 Certified Institution
Re-Accredited by NAAC with A+ and Recognized by UGC with Section 2(f) and 12(B)
NBA Accredited UG Programmes : AERO | CSE
T.M. Palayam, Coimbatore-641105
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
CCS335 – Neural Network and Deep Learning Lab
SEMESTER - VI
REGULATION 2021
NAME : .……………………………………….
REG NO : ………………………………………..
DEPARTMENT : .……………………………………….
2. NEHRU INSTITUTE OF ENGINEERING AND TECHNOLOGY
(AUTONOMOUS)
Thirumalayampalayam, Coimbatore-641 105
(Approved by AICTE, New Delhi and Affiliated to Anna University,
Chennai) An ISO 9001:2015 and ISO 14001:2015 Certified Institution
Re-Accredited by NAAC with A+ and Recognized by UGC with Section 2(f)
and 12(B) NBA Accredited UG Programmes : AERO | CSE
T.M. Palayam, Coimbatore-641105
Certified that this is a bonafide record of work done in CCS335 Neural Networks and Deep Learning Lab
by Mr. /Ms.
Reg.No of this Institution as prescribed by Anna University, Chennai
For the VI Semester course in Computer Science and Engineering branch during the academic year 2023-
2024.
Staff In charge:
Date : HOD
Submitted for the university practical examination held on at Nehru Institute of
Engineering and Technology, Coimbatore – 641105.
……………………………………. …………………………………….
Internal Examiner External Examiner
3. CCS33 NEURAL NETWORK AND DEEP LEARNING LABORATORY L T P C
3 0 2 4
OBJECTIVES:
The main objectives of this course are to:
To understand the basic in deep neural networks
To understand the basic of associative memory and unsupervised learning network.
To apply CNN architecture of deep neural networks.
To analyze the key computations underling deep learning, then use them to build and train deep neural
networks for various tasks.
To apply auto encoders and generative models for suitable applications.
LIST OF EXPERIMENTS:
1. Implement simple vector addition in Tensor Flow.
2. Implement a regression model in Keras.
3. Implement a perception in TensorFlow/Keras Environment.
4. Implement a Feed Forward Network in TensorFlow/Keras.
5. Implement an image classifier using CNN in TensorFlow/Keras.
6. Improve the deep Learning model by fine tuning hyper parameters.
7. Implement a Transfer Learning concept in image classification.
8. Using a pre trained model on Keras for transfer learning.
9. Perform Sentimental Analysis using RNN.
10. Implement an LSTM based Auto encoding inTensorflow/Keras.
11. Image generation using GAN.
ADDITIONAL EXPERIMENTS
12. Train a deep Learning model to classify a given image using pre trained model.
13. Recommendation system from sales data using Deep Learning.
14. Implement Object detection using CNN.
15. Implement any simple Reinforcement Algorithm for an NLP problem.
TOTAL: 60 PERIODS
OUTCOMES:
After the Completion of the course, the students will be able to:
Apply Convolution Neural Network for image processing.
Understand the basics of associative memory and unsupervised learning networks.
Apply CNN and its variants for suitable applications.
Analyze the key computations underlying deep learning and use them to build and train deep neural
networks for various tasks.
Apply auto encoders and generative models for suitable applications.
SOFTWARE REQUIRED:
● Jupiter Notebook, Colab.
4. LIST OF EXPERIMENTS
EX.NO. DATE NAME OF THE EXPERIMENT
PAGE
NO. SIGNATURE
1.
Implement simple vector addition in Tensor
Flow.
2. Implement a regression model in Keras.
3.
Implement a perception in TensorFlow/Keras
Environment.
4.
Implement a Feed Forward Network in
TensorFlow/Keras.
5.
Implement an image classifier using CNN in
TensorFlow/Keras.
6.
Improve the deep Learning model by fine
tuning hyper parameters.
7.
Implement a Transfer Learning concept in
image classification.
8.
Using a pre trained model on Keras for
transfer learning.
9. Perform Sentimental Analysis using RNN.
10.
Implement an LSTM based Auto encoding
inTensorflow/Keras.
11. Image generation using GAN.
12.
Train a deep Learning model to classify a
given image using pre trained model.
13.
Recommendation system from sales data
using Deep Learning.
14. Implement Object detection using CNN.
15.
Implement any simple Reinforcement
Algorithm for an NLP problem.
5. EXP.NO:0 DATE:
BASIC OF TENSERFLOW
Aim: To study the basic of tensor flow along python programs using Colab laboratory.
Questions:
i. Architecture of tensor flow
ii. How to convert Numpy array to tensor flow
iii. Matrix using tensor flow
Description:
i. Architecture of Tensor Flow
TensorFlow is an end-to-end open-source machine learning platform developed by Google.
It is scalable and flexible, running on various devices like data centers and mobile phones.
Computation in TensorFlow is represented by a directed graph with nodes as
operations/functions and edges as input/output flows.
Tensors, multi-dimensional arrays, serve as inputs and outputs in TensorFlow.
The architecture includes device and network layers, kernel implementations, distributed
components, and API layers in C.
Advanced features include custom operations, custom gradients, TensorFlow Eager
Execution, TensorFlow Keras, TensorFlow Probability, and TensorFlow Model
Optimization.
TensorFlow is widely used for image classification, natural language processing, time-series
analysis, generative models, reinforcement learning, and anomaly detection.
6. ii. Convert Numpy array to tensor flow
The syntax for converting numpy array to tensor flow is :
tf.convert_to_tensor(value, dtype=None, dtype_hint=None, name=None)
value: The input object to be converted into a tensor. It can be a NumPy array, Python list,
scalar value, etc. This parameter is mandatory.
dtype: (Optional) The data type of the elements in the resulting tensor. If not specified, the data
type is inferred from the type of the value. It allows to explicitly set the data type for the tensor.
dtype_hint: (Optional) When dtype is None, dtype_hint is an optional preferred data type for the
resulting tensor. It serves as a hint to TensorFlow about the preferred data type but has no effect
if the conversion is not possible. This parameter is useful when you want to suggest a preferred
data type without enforcing it.
name: (Optional) An optional name for the resulting tensor. If a new tensor is produced during
the conversion, this name can be used to identify it in the TensorFlow graph.
The tf.convert_to_tensor() function is widely employed to transform various types of objects, including
NumPy arrays, into TensorFlow tensors. The resulting tensor can then be seamlessly integrated into
TensorFlow operations and workflows.
iii. Matrix using Tensorflow
The syntax for creating a matrix using TensorFlow's `tf.constant()` is :
tf.constant(value, dtype=None, shape=None, name='Const', verify_shape=False)
value: The values to be used for initializing the constant tensor. In the context of creating a
matrix, this would be a nested list representing the matrix elements.
dtype: (Optional) The data type of the elements in the tensor. If not specified, the data type is
inferred from the type of the `value`.
shape: (Optional) The shape of the tensor. For creating a matrix, you can specify the shape as a
tuple representing the number of rows and columns.
name: (Optional) An optional name for the operation.
verify_shape: (Optional) A boolean that controls whether to check if the shape of the provided
value matches the specified shape argument. If set to `True` and the shapes do not match, a
`ValueError` will be raised.
8. Output:
TensorFlow Matrix:
tf.Tensor(
[[1 2 3]
[4 5 6]], shape=(2, 3), dtype=int32)
Result:
Thus the python program using tensor flow for above experiment is successfully executed and
verified.
9. EXP.NO:1 DATE:
Aim: To Implement simple vector addition in Tensor Flow using Colab laboratory.
Questions:
1. Scalar
2. Checking the dimensions of scalar
3. Vector
4. Checking the dimensions of vector
5. Matrix
6. Mathematical Operation
i. Addition
ii. Subtraction
iii. Multiplication
iv. Division
v. Transpose
vi. Dot Product
Algorithm:
1. Start Colab:
a. Open Google Colab in your web browser.
b. Create a new notebook.
2. Scalar:
a. Import TensorFlow.
b. Define a scalar using `tf.constant()`.
3. Checking the Dimensions of Scalar:
a. Use `scalar.ndim` to find dimension of scalar.
4. Vector:
a. Define a vector using `tf.constant()` with a 1D array.
5. Checking the Dimensions of Vector:
a. Use `vector.ndim` to find dimension of vector.
6. Matrix:
a. Define a matrix using `tf.constant()` with a 2D array.
7. Mathematical Operations:
i. Addition:
a. Use `tf.add()` for element-wise addition.
10. ii. Subtraction:
a. Use `tf.subtract()` for element-wise subtraction.
iii. Multiplication:
a. Use `tf.multiply()` for element-wise multiplication.
iv. Division:
a. Use `tf.divide()` for element-wise division.
v. Transpose:
a. Use `tf.transpose()` for matrix transposition.
vi. Dot Product:
a. Use `tf.tensordot()` for matrix multiplication.
8. Run the Code:
a. Execute each cell in the Colab notebook to see the results.
Program:
1.Scalar:
Output:
<tf.Tensor: shape=(), dtype=int32, numpy=7>
2.Dimensions of Scalar:
Output:
0
3.Vector:
# importing packages
import tensorflow as tf
# creating a scalar
scalar = tf.constant(7)
scalar
#checking dimensions of scalar
scalar.ndim
# importing
packages import
tensorflow as tf
# create a vector
vector = tf.constant([10,
10]) vector
11. Output:
<tf.Tensor: shape=(2,), dtype=int32, numpy=array([10, 10], dtype=int32)>
4.Dimensions of Vector:
Output:
1
5.Matrix:
Output:
tf.Tensor(
[[1 2]
[3 4]], shape=(2, 2), dtype=int32)
The number of dimensions of a matrix is :2
6.Mathematical Operations:
i.Addition:
Output:
tf.Tensor(
[[ 3 6]
[ 9 12]], shape=(2, 2), dtype=int32)
# importing packages
import tensorflow as tf
# creating two tensors
matrix = tf.constant([[1, 2], [3, 4]])
matrix1 = tf.constant([[2, 4], [6, 8]])
# addition of two matrices
result = tf.add(matrix, matrix1)
print(result)
# checking the dimensions of vector
vector.ndim
# importing packages
import tensorflow as tf
# creating a matrix
matrix = tf.constant([[1, 2], [3, 4]])
print(matrix)
print('the number of dimensions of a matrix is :
'+str(matrix.ndim))
13. iii.Division:
Output:
tf.Tensor(
[[2. 2.]
[2. 2.]], shape=(2, 2), dtype=float64)
iv. Transpose:
Output:
tf.Tensor(
[[1 3]
[2 4]], shape=(2, 2), dtype=int32)
# importing packages
import tensorflow as tf
# creating two tensors
matrix = tf.constant([[1, 2],[3, 4]])
matrix1 = tf.constant([[2, 4],[6, 8]])
# division of two matrices
result=tf.divide(matrix,matrix1)
print(result)
# importing packages
import tensorflow as tf
# creating a matrix
matrix = tf.constant([[1, 2], [3, 4]])
# transpose of the matrix
print(tf.transpose(matrix))
14. v. Dot Product:
Output:
dot product of matrices is : tf.Tensor(
[[ 7 10]
Result:
Thus the python program using tensor flow for about mathematical operations is successfully
executed and verified.
# importing packages
import tensorflow as tf
# creating a matrix
matrix = tf.constant([[1, 2], [3, 4]])
# dot product of matrices
print('dot product of matrices is : ' +
str(tf.tensordot(matrix, matrix, axes=1)))
15. EXP.NO:2 DATE:
Aim: To Implement a regression model in Keras using mnist -dataset in Colab laboratory.
Dataset Details:
Mnist Dataset: https://www.kaggle.com/datasets/oddrationale/mnist-in-csv
Objective:
Step 1 - Import the library
Step 2 - Loading the Dataset
Step 3 - Creating Regression Model
Step 4 - Compiling the model
Step 5 - Fitting the model
Step 6 - Evaluating the model
Step 7 - Predicting the output
Description:
1.Import The Libraries:
Import necessary libraries: Pandas, Numpy, Keras, Scikit-learn, etc., .
2.Upload The Dataset:
Upload the dataset in drive using mount drive method.
3.Load The Dataset:
Load the mnist_train and mnsit_test datasets.
4.Data Preprocessing:
Change the pixels od the dataset to perform further actions.
5.Creating Regression Model:
Create a sequential model with two args.
Add linear stack of layers and use activation function ‘relu’.
16. 6.Compiling the Model:
Compile the model with the Adam optimizer, mean squared error as the loss function,
and mean absolute error as the evaluation metric.
7.Fitting the Model:
Split the dataset into training and testing sets using scikit-learn.
Standardize the input features using the StandardScaler from scikit-learn.
Use training data for fitting the model and use paramaters like epochs, batch_size,
verbose, etc., .
8.Evaulating The Model:
Use model.evaluate to evaluate the model and it will give us the loss and the accuracy.
Here we have also printed the score.
9.Predicting The Output:
Use another part of the data that we get from test_train_split i.e. test data.
We will use it and predict the output.
Program:
1.Import The Library:
2.Upload The Dataset:
drive.mount('/content/drive')
Output:
Mounted at /content/drive
import pandas as pd
import numpy as np
from keras.datasets import mnist
from sklearn.model_selection import train_test_split
from keras.models import Sequential
from keras.layers import Dense
from keras.layers import Dropout
from google.colab import drive
19. 9.Predicting the Output:
Output:
1875/1875 [==============================] - 10s 5ms/step
[[ 7.6505547 -5.039996 -4.8032265 ... -5.1202197 -4.11554 -4.5914993]
[ 8.687883 -5.6656256 -5.358442 ... -5.6097336 -4.4189353 -4.6995463]
[ 5.088747 -3.361604 -3.19289 ... -3.178188 -2.7151685 -2.9893024]
...
[ 6.4936686 -4.0753646 -3.68436 ... -4.2753725 -3.3604608 -3.5153835]
[ 5.344781 -3.5582738 -3.5012681 ... -3.5117133 -2.885717 -3.028985 ]
[ 5.977292 -3.7096646 -3.6107407 ... -3.9403937 -3.1786413 -3.3968258]]
Result:
Thus the python program using tensor flow for Regression in Keras is successfully executed and
verified.
y_pred = model.predict(X_test)
print(y_pred)
20. EXP.NO:3 DATE:
Aim: To Implement a Perceptron using Keras/ Tensor flow environment.
Project Details:
https://www.geeksforgeeks.org/multi-layer-perceptron-learning-in-tensorflow/
https://www.geeksforgeeks.org/single-layer-perceptron-in-tensorflow/
Objective:
Step1: Import necessary libraries
Step 2: Now load the dataset using “Keras” from the imported version of tensor flow.
Step 3: Now display the shape and image of the single image in the dataset. The image size contains
a 28*28 matrix and length of the training set is 60,000 and the testing set is 10,000.
Step 4: Now normalize the dataset in order to compute the calculations in a fast and accurate
manner.
Step 5: Building a neural network with single-layer perception. Here we can observe as the model
is a single-layer Perceptron that only contains one input layer and one output layer there is
no presence of the hidden layers.
Step 6: Output the accuracy of the model on the testing data.
Description:
1.Import the Libraries:
Essential libraries are imported including TensorFlow and Keras for building and training neural
networks, Numpy for numerical operations, and Matplotlib for visualization.
2.Upload the Dataset:
Dataset is uploaded in drive using mount drive method.
3.Load the Dataset:
The MNIST dataset, consisting of 60,000 training images and 10,000 testing images of
handwritten digits (0-9), is loaded.
4.Displaying Dataset:
Information about the dataset is printed, including the shapes of training and testing data.
Additionally, the first image from the training set is displayed for visualization.
21. 5.Normalizing the Dataset:
The pixel values of the images are normalized to a range between 0 and 1 by dividing
each pixel value by 255.0.
This standardizes the data and helps in faster convergence during training.
6.Flattening the Image:
The input images are flattened from a 28x28 matrix to a 1D array of length 784 to match
the input shape expected by the model.
7.Building the Model:
Building a neural network with single-layer perception.
Here we can observe as the model is a single-layer perceptron that only contains one
input layer and one output layer there is no presence of the hidden layers.
8.Output Accuracy:
The model's accuracy is evaluated on the testing data using the evaluate () method.
The accuracy is then printed out as a percentage, indicating how well the model
generalizes to unseen data.
Program:
1.Import The Libraries:
2.Upload The Dataset:
drive.mount('/content/drive')
import numpy as np
import pandas as pd
import tensorflow as tf
from tensorflow import keras
import matplotlib.pyplot as plt
%matplotlib inline
from google.colab import drive
import matplotlib.pyplot as plt
22. 3.Load The Dataset:
4.Displaying The Dataset:
Output:
Training data shape: (10000, 784)
Testing data shape: (60000, 784)
Shape of the first image: (784,)
<matplotlib.image.AxesImage at 0x796ebbf83d60>
mnist_train = pd.read_csv("/content/drive/MyDrive/mnist_test.csv")
mnist_test = pd.read_csv("/content/drive/MyDrive/mnist_train.csv")
x_train = mnist_train.drop("label", axis=1).values
y_train = mnist_train["label"].values
x_test = mnist_test.drop("label", axis=1).values
y_test = mnist_test["label"].values
print("Training data shape:", x_train.shape)
print("Testing data shape:", x_test.shape)
print("Shape of the first image:", x_train[0].shape)
# Reshape the flattened image into a 2D array and display first image
image = np.reshape(x_train[0], (28, 28))
plt.imshow(image)
24. 2. Output Accuracy:
Output:
1875/1875 [==============================] - 3s 2ms/step - loss: 8.6323e-04 -
accuracy: 0.0987
Accuracy: 9.87%
Result:
Thus the python program using tensor flow for Regression in Keras is successfully executed and
verified.
evaluation_results = model.evaluate(x_test_flatten, y_test)
accuracy = evaluation_results[1]
# Convert accuracy to percentage
accuracy_percentage = accuracy * 100
# Print accuracy
print("Accuracy: {:.2f}%".format(accuracy_percentage))
25. EXP.NO:4 DATE:
Aim: To Implement a Feed Forward network using Keras/ Tensor flow environment.
Project Details:
https://www.analyticsvidhya.com/blog/2016/10/an-introduction-to-implementing-neural-networks-using-
tensorflow/
Objective:
A typical implementation of Neural Network would be as follows:
Step 1: Define Neural Network architecture to be compiled.
Step 2: Transfer data to your model.
Step 3: Under the hood, the data is first divided into batches, so that it can be ingested. The
batches are first preprocessed, augmented and then fed into Neural Network for
training
Step 4: The model then gets trained incrementally.
Step 5: Display the accuracy for a specific number of time steps.
Step 6: After training save the model for future use.
Step 7: Test the model on a new data and check how it performs
Program:
i. Implementing Scikit-learn
The usual workflow of running a program in TensorFlow is as follows:
Build a computational graph, this can be any mathematical operation TensorFlow supports.
Initialize variables, to compile the variables defined previously
Create session, this is where the magic starts!
Run graph in session, the compiled graph is passed to the session, which starts its
execution. Close session, shutdown the session.
Few terminologies used in TensorFlow;
26. placeholder: A way to feed data into the graphs
feed_dict: A dictionary to pass numeric values to computational graph
Step 1: Define Neural Network architecture to be compiled.
We can control our models randomness
Set Directory Paths
Step 2: Transfer data to your model.
Output:
27. Step 3: Under the hood, the data is first divided into batches, so that it can be ingested. The batches
are first preprocessed, augmented and then fed into Neural Network for training.
Output:
28. Step 4: The model then gets trained incrementally.
Step 5: Display the accuracy for a specific number of time steps.
30. Output:
Step 7: Test the model on a new data and check how it performs
Output:
Result:
Thus the python program using tensor flow for Regression in Keras is successfully executed and
verified.
31. EXP.NO:5 DATE:
Aim: To Implement an Image classifier using CNN in Keras/ Tensor flow environment.
Project Details:
https://www.tensorflow.org/tutorials/images/cnn
Objective:
Step 1: Import TensorFlow.
Step 2: Download and prepare the CIFAR10 dataset.
Step 3: Verify the data.
Step 4: Create the convolutional base.
Step 5: Add dense layers on top.
Step 6: Compile and train the model.
Step 7: Evaluate the model.
Program:
Step 1: Import TensorFlow.
Output:
Step 2: Download and prepare the CIFAR10 dataset.
The CIFAR10 dataset contains 60,000 color images in 10 classes, with 6,000 images in each class.
The dataset is divided into 50,000 training images and 10,000 testing images. The classes are mutually
exclusive and there is no overlap between them.
32. Output:
Step 3: Verify the data.
To verify that the dataset looks correct, let's plot the first 25 images from the training set and display the
class name below each image:
Output:
33. Step 4: Create the convolutional base.
The 6 lines of code below define the convolutional base using a common pattern: a stack
of Conv2D and MaxPooling2D layers. As input, a CNN takes tensors of shape (image height, image
width, color channels), ignoring the batch size. If you are new to these dimensions, color channels
refers to (R, G, and B). In this example, you will configure your CNN to process inputs of shape (32,
32, 3), which is the format of CIFAR images. You can do this by passing the argument input shape to
your first layer.
Output:
34. Step 5: Add dense layers on top.
To complete the model, you will feed the last output tensor from the convolutional base (of
shape (4, 4, and 64)) into one or more Dense layers to perform classification. Dense layers
take vectors as input (which are 1D), while the current output is a 3D tensor. First, you will
flatten (or unroll) the 3D output to 1D, then add one or more Dense layers on top. CIFAR has
10 output classes, so you use a final dense layer with 10 outputs.
Output:
Step 6: Compile and train the model.
37. EXP.NO:6 DATE:
Aim: To Implement a Deep learning model by fine turning parameters.
Project Details:
https://pyimagesearch.com/2019/06/03/fine-tuning-with-keras-and-deep-learning/
https://www.analyticsvidhya.com/blog/2021/05/tuning-the-hyperparameters-and-layers-of-neural-
network-deep-learning/
Objective:
Step 1: Imports useful packages for Neural Network modeling.
Step 2: Makes accuracy the scorer metric.
Step 3: Load Dataset
Step 4: Function will return returns the score of the cross-validation.
Step 5: Sets the range of hyper parameters and run the Bayesian Optimization.
Step 6: Best hyper parameters.
Step 7: Creates a function for tuning the Neural Network hyper parameters and layers.
Step 8: Tuned hyper parameters and layers.
Step 9: Fitting Neural Network.
Program:
Step 1: Imports useful packages for Neural Network modeling.
Step 2: Makes accuracy the scorer metric.
38. Step 3: Load Dataset
Step 4: Function will return returns the score of the cross-validation.
39. Step 5: Sets the range of hyper parameters and run the Bayesian Optimization.
Output:
40. Step 6: Best hyper parameters.
Output:
Step 7: Creates a function for tuning the Neural Network hyper parameters and layers.
43. Step 9: Fitting Neural Network.
Output:
Result:
Thus the python program using tensor flow for Regression in Keras is successfully executed and
verified.
44. EXP.NO:7 DATE:
Aim: To Implement a Transfer learning concept in image Classification.
Project Details:
https://www.geeksforgeeks.org/multiclass-image-classification-using-transfer-learning/
https://www.analyticsvidhya.com/blog/2021/10/understanding-transfer-learning-for-deep-
learning/
Objective:
Step 1: Importing Libraries
Step 2: Uploading Data via Kaggle API
Step 3: Designing Our CNN Model with help of Pre–Trained Model
Step 4: Image Augmentation (For preventing the issue of over fitting)
Step 5: Training Our Model.
Step 6: Making Predictions.
Program:
Step 1: Importing Libraries.
45. Step 2: Uploading Data via Kaggle API
Step 3: Designing Our CNN Model with help of Pre–Trained Model.
Step 4: Image Augmentation (For preventing the issue of over fitting).
48. EXP.NO:8 DATE:
Aim: To Implement a Pretrained model for Keras for transfer learning.
Project Details:
https://www.geeksforgeeks.org/multiclass-image-classification-using-transfer-learning/
https://www.analyticsvidhya.com/blog/2017/06/transfer-learning-the-art-of-fine-tuning-a-pre-trained-
model/.
Objective:
Step 1: Retrain the output dense layers only.
Step 2: Freeze the weights of first few layers.
Program:
Step 1: Retrain the output dense layers only.
Step 2: Freeze the weights of first few layers.
50. EXP.NO:9 DATE:
Aim: To perform Sentimental Analysis using RNN.
Project Details:
https://towardsdatascience.com/a-beginners-guide-on-sentiment-analysis-with-rnn-9e100627c02e.
https://www.kaggle.com/code/rahulagg/sentiment-analysis-using-rnn.
Objective:
Step 1: Importing Libraries and Dataset
Step 2: load in training and test data.
Step 3: Loaded dataset with 25000 training samples, 25000 test samples.
Step 4: Pad sequences.
Step 5: Design an RNN model for sentiment analysis.
Step 6: Train and evaluate our model.
Program:
Step 1: Importing Libraries and Dataset.
The data: We will use Recurrent Neural Networks, and in particular LSTMs, to perform sentiment
analysis in Keras. Conveniently, Keras has a built-in IMDb movie reviews data set that we can use.
Step 2: load in training and test data.
Step 3: Loaded dataset with 25000 training samples, 25000 test samples.
51. Output:
That the review is stored as a sequence of integers. These are word IDs that have been pre-assigned to
individual words, and the label is an integer (0 for negative, 1 for positive).
Output:
Maximum review length and minimum review length.
Maximum review length: 2697
Minimum review length: 14
52. Step 4: Pad sequences.
Step 5: Design an RNN model for sentiment analysis.
Output:
Step 6: Train and evaluate our model.
53. Output:
Result:
Thus the python program using tensor flow for Sentimental Analysis using RNN is successfully
executed and verified.
54. EXP.NO:10 DATE:
Aim: To Implement an LSTM based Auto encoding inTensorflow/Keras.
Project Details:
https://analyticsindiamag.com/introduction-to-lstm-autoencoder-using-
keras/#:~:text=LSTM%20autoencoder%20is%20an%20encoder,original%20structure%20using
%20a%20decoder.&text=Simple%20Neural%20Network%20is%20feed,ventures%20just%20in
%20one%20direction.
Objective:
Step 1: Import libraries required for this project
Step 2: Read the data
Step 3: Split the data
Step 4: Pre-Processing of Data
Step 5: Create a sequence with historical data
Step 6: Creating an LSTM Auto encoder Network
Step 7: Fitting the Model
Step 8: Evaluation
Step 9: Actual Value of Test Data
Step 10: Prediction on Test Data.
Program:
Step 1: Import libraries required for this project.
Step 2: Read the data.
55. Step 3: Split the data.
Step 4: Pre-Processing of Data.
Step 5: Create a sequence with historical data.
57. Step 7: Fitting the Model.
Step 8: Evaluation.
Step 9: Actual Value of Test Data.
Step 10: Prediction on Test Data.
Result:
Thus the python program using LSTM based Auto encoding in Keras is successfully executed and
verified.
58. EXP.NO: 11 DATE:
Aim: To Implement an Image generation using GAN.
Project Details:
https://www.scaler.com/topics/deep-learning/gans-image-generation/
https://www.analyticsvidhya.com/blog/2021/03/why-are-generative-adversarial-networksgans-so-
famous-and-how-will-gans-be-in-the-future/.
Objective:
Step 1: Reading the Dataset
Step 2: Defining the Generator.
Step 3: Defining the Discriminator.
Step 4: Computing the Loss Function
Step 5: Optimizing the Loss
Step 6: Generating Handwritten Digits.
Requirements
Before creating the GAN's image generation module, we must import a few libraries.
We will import all the functions, layers, and dataset loaders from TensorFlow.
We will also import Numpy (a math library) and matplotlib (a plotting library).
Building the Model
The GAN we want to create comprises two major parts:
Generator
Discriminator.
The Generator is responsible for creating novel images, while the Discriminator is responsible for
understanding how good the generated image is.
Program:
Step 1: Reading the Dataset.
The MNIST (Modified National Institute of Standards and Technology) dataset. This dataset has more
handwritten digits of 28x28 and is one of computer vision's most widely used datasets. The MNIST is
an easy dataset for a GAN such as the one we are building, as it has small, single channels images.
59. Step 2: Defining the Generator
The job of the Generator (D) is to create realistic images that the Discriminator fails to understand are
fake. Thus, the Generator is an essential component that enables a GANs image generation ability.
The architecture we consider in this article comprises fully connected layers (FC) and Leaky ReLU
activations. The final layer of the Generator has a TanH activation rather than a LeakyReLU. This
replacement was done because we wanted to convert the generated image to the same range as the
original MNIST dataset (-1, 1).
62. Step 6: Generating Handwritten Digits.
We trained the GAN for around 10,000 epochs with a batch size of 32. We save the generated images
every 200 epochs in the images folder.
Output:
Result:
Thus the python program using Image generation using GAN in Keras is successfully executed
and verified.
64. EXP.NO:12 DATE:
Aim: To implement a train a deep Learning model to classify a given image using pre trained model.
Project Details:
https://learnopencv.com/pytorch-for-beginners-image-classification-using-pre-trained-models/.
https://www.analyticsvidhya.com/blog/2017/06/transfer-learning-the-art-of-fine-tuning-a-pre-trained-
model/
Objective:
Step 1: Reading the input image.
Step 2: Performing transformations on the image. For example – resize, center crop, normalization, etc.
Step 3: Forward Pass: Use the pre-trained weights to find out the output vector. Each element in this
output vector describes the confidence with which the model predicts the input image belongs to a
particular class.
Step 4: Based on the scores obtained (elements of the output vector mentioned in step 3), display the
predictions.
Step 5: Load the pre-trained model
Step 6: Specify image transformations
Step 7: Load the input image and pre-process it
Step 8: Model Inference
65. Program:
Step 1: Reading the input image.
Step 2: Performing transformations on the image. For example – resize, center crop, normalization, etc.
Step 3: Forward Pass: Use the pre-trained weights to find out the output vector. Each element in this
output vector describes the confidence with which the model predicts the input image belongs to a
particular class.
Step 4: Based on the scores obtained (elements of the output vector mentioned in step 3), display the
predictions.
Step 5: Load the pre-trained model.
66. Step 6: Specify image transformations.
Step 7: Load the input image and pre-process it.
Output:
68. Result:
Thus the python program using a deep learning model to classify a given image using pre trained
model in Keras is successfully executed and verified.
69. EXP.NO:13 DATE:
Aim: To Implement a recommendation system from sales data using Deep Learning.
Project Details:
https://www.javatpoint.com/sales-prediction-using-machine-learning.
https://www.analyticsvidhya.com/blog/2020/08/building-sales-prediction-web-application-using-
machine-learning-dataset/
Objective:
Step 1: Importing Libraries.
Step 2: Loading and Exploration of the Data.
Step 3: EDA (Exploratory Data Analysis).
Step 4: Determining Time Series Stationary.
Step 5: Differencing.
Program:
Step 1: Importing Libraries.
75. EXP.NO:14 DATE:
Aim: To Implement object detection using CNN.
Project Details:
https://www.kaggle.com/code/silviua/object-detection-cnn
https://www.analyticsvidhya.com/blog/2018/11/implementation-faster-r-cnn-python-object-detection/
Objective:
Step 1: Load data, process and save as Numpy zip
Step 2: Load the processed training images
Step 3: Create the model
Step 4: Callbacks
Step 5: Training method
Step 6: Load the model for tests
Program:
Step 1: Load data, process and save as Numpy zip
84. EXP.NO:15 DATE:
Aim: To Implement a simple Reinforcement Algorithm for an NLP problem.
.
Project Details:
https://www.analyticsvidhya.com/blog/2022/03/a-hands-on-introduction-to-reinforcement-
learning-with-python/.
https://github.com/ml-for-nlp/reinforcement-learning.
Objective:
Step 1: To Check Random Package
Step 2: Number of Steps Remaining
Step 3: Initialization of Reward Points in Default Constructor.
Program:
Step 1: To Check Random Package.
My Environment:
85. Step 2: Number of Steps Remaining.
Step 3: Initialization of Reward Points in Default Constructor.
86. Output:
Result:
Thus the python program using simple Reinforcement Algorithm for an NLP problem is
successfully executed and verified.