## Before you go, check out these stories!

0 Classify Handwritten Digits using Deep learning with Tensorflow by@itsvinayak

# Classify Handwritten Digits using Deep learning with Tensorflow  ### @itsvinayakvinayak

Computer Science and Engineering student

Deep learning is a subpart of machine learning and artificial intelligence which is also known as deep neural network this networks capable of learning unsupervised from provided data which is unorganized or unlabeled. today, we will implement a neural network in 6 easy steps using TensorFlow to classify handwritten digits.

Modules required :

NumPy:

``\$ pip install numpy ``

Matplotlib:

``\$ pip install matplotlib ``

Tensorflow:

``\$ pip install tensorflow ``

## Steps to follow:

Step 1 : Importing all dependence

``````import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt``````

Step 2 : Import data and normalize it

``````mnist = tf.keras.datasets.mnist

x_train = tf.keras.utils.normalize(x_train,axis=1)
x_test = tf.keras.utils.normalize(x_test,axis=1)``````

Step 3 : view data

``````def draw(n):
plt.imshow(n,cmap=plt.cm.binary)
plt.show()

draw(x_train)`````` Step 4 : make a neural network and train it

``````#there are two types of models
#sequential is most common

model = tf.keras.models.Sequential()

#reshape

loss='sparse_categorical_crossentropy',
metrics=['accuracy']
)
model.fit(x_train,y_train,epochs=3)
`````` Step 5 : check model accuracy and loss

``````val_loss,val_acc = model.evaluate(x_test,y_test)
print("loss-> ",val_loss,"\nacc-> ",val_acc)`````` Step 6 : prediction using model

``````predictions=model.predict([x_test])
print('lable -> ',y_test)
print('prediction -> ',np.argmax(predictions))

draw(x_test)``````                 #### Tags

Become a Hackolyte