DL Practical 3 (1)
DL Practical 3 (1)
/usr/bin/env python
# coding: utf-8
# In[173]:
# In[174]:
'''
Theory:
# In[175]:
'''
Experiment Details
Software Requirements
Python 3.7 or higher
TensorFlow 2.x
Scikit-learn
Matplotlib
'''
# In[176]:
# Procedure
# Step 1: Import necessary libraries
import numpy as np
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras.utils import plot_model # For visualizing the
model
from sklearn.datasets import make_moons
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.metrics import accuracy_score
import matplotlib.pyplot as plt
from tensorflow.keras import Input
# In[177]:
# In[178]:
image_no = 10
plt.matshow(X_train[image_no])
y_train[image_no]
# In[179]:
# In[180]:
# In[181]:
# In[ ]:
# In[182]:
# In[183]:
# In[184]:
# In[185]:
# Predictions
y_pred = model.predict(X_test_flattened)
# In[186]:
image_no = 15
plt.matshow(X_test[image_no])
print('label', y_test[image_no])
y_pred[0]
print('predicted', np.argmax(y_pred[image_no]))
# In[187]:
# Predictions
y_pred = model.predict(X_test_flattened)
y_pred[0]
print(np.argmax(y_pred[image_no]))
# In[188]:
# In[189]:
# In[190]:
import seaborn as sn
plt.figure(figsize = (10,7))
sn.heatmap(cm, annot=True, fmt='d')
plt.xlabel('Predicted')
plt.ylabel('Truth')
# In[191]:
'''
Conclusions:
By completing this experiment, students will gain hands-on experience in
building, training, and evaluating a neural network for digit
classification using the MNIST dataset. They will understand the impact
of various components such as activation functions, loss functions, and
optimizers on the model's performance'''
# In[192]:
How would you modify the network to handle RGB images instead of
grayscale?'''