<gh_stars>1-10
# -*- coding: utf-8 -*-
'''Written By : <NAME>'''
"""Handwritten Digit Recognition

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1IlfqCtzB3QEc3pLn63_Yfnd650wbvQ5Q

# Importing Tensorflow and mnist handwriting data
"""

import tensorflow as tf
import numpy as np
mnist=tf.keras.datasets.mnist
(x_train,y_train),(x_test,y_test)=mnist.load_data()

"""# Visualizing"""

import matplotlib.pyplot as plt
for i in range(3):
    plt.imshow(x_train[i].reshape(28,28))
    plt.show()

"""# Normalizing Data between 0,1"""

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

"""# Creating Models"""

model=tf.keras.models.Sequential()
## Flatting out the 2 dimensional tensors to 1 Dimension
model.add(tf.keras.layers.Flatten())
##Hidden Layers with activation function RELU and size 16
model.add(tf.keras.layers.Dense(512,activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(512,activation=tf.nn.relu))
##Output Layer with activation softmax and size 10 for 10 digits recognition
model.add(tf.keras.layers.Dense(10,activation=tf.nn.softmax))

"""# Compiling the model to form neural network architecture defined"""

##Compiling Model with optimizer function ADAM , Loss function SPARSE CATEGORICAL CROSSENTROPY
model.compile(optimizer='adam',loss='sparse_categorical_crossentropy',metrics=['accuracy'])

"""# Training Process: Model Trains"""

##Training Model
model.fit(x_train,y_train,epochs=5)

"""# Evaluating models with test set"""

##Evaluating Model
val_loss,val_acc=model.evaluate(x_test,y_test)
print(val_loss)
print(val_acc)

"""# Predicting"""

prediction=model.predict(x_test)

"""# Retrieving most likely predicted Value using numpy"""

##Showing Handwritten digit image with prediction
for i in range(100):
    plt.imshow(x_test[i].reshape(28,28))
    print(prediction[i])
    num=np.argmax(prediction[i])
    print(num)
    plt.show()
# -*- coding: utf-8 -*-
'''Written By : <NAME>'''
"""Handwritten Digit Recognition

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1IlfqCtzB3QEc3pLn63_Yfnd650wbvQ5Q

# Importing Tensorflow and mnist handwriting data
"""

import tensorflow as tf
import numpy as np
mnist=tf.keras.datasets.mnist
(x_train,y_train),(x_test,y_test)=mnist.load_data()

"""# Visualizing"""

import matplotlib.pyplot as plt
for i in range(3):
    plt.imshow(x_train[i].reshape(28,28))
    plt.show()

"""# Normalizing Data between 0,1"""

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

"""# Creating Models"""

model=tf.keras.models.Sequential()
## Flatting out the 2 dimensional tensors to 1 Dimension
model.add(tf.keras.layers.Flatten())
##Hidden Layers with activation function RELU and size 16
model.add(tf.keras.layers.Dense(512,activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(512,activation=tf.nn.relu))
##Output Layer with activation softmax and size 10 for 10 digits recognition
model.add(tf.keras.layers.Dense(10,activation=tf.nn.softmax))

"""# Compiling the model to form neural network architecture defined"""

##Compiling Model with optimizer function ADAM , Loss function SPARSE CATEGORICAL CROSSENTROPY
model.compile(optimizer='adam',loss='sparse_categorical_crossentropy',metrics=['accuracy'])

"""# Training Process: Model Trains"""

##Training Model
model.fit(x_train,y_train,epochs=5)

"""# Evaluating models with test set"""

##Evaluating Model
val_loss,val_acc=model.evaluate(x_test,y_test)
print(val_loss)
print(val_acc)

"""# Predicting"""

prediction=model.predict(x_test)

"""# Retrieving most likely predicted Value using numpy"""

##Showing Handwritten digit image with prediction
for i in range(100):
    plt.imshow(x_test[i].reshape(28,28))
    print(prediction[i])
    num=np.argmax(prediction[i])
    print(num)
    plt.show()
# -*- coding: utf-8 -*- Written By : <NAME> Handwritten Digit Recognition  Automatically generated by Colaboratory.  Original file is located at     https://colab.research.google.com/drive/1IlfqCtzB3QEc3pLn63_Yfnd650wbvQ5Q  # Importing Tensorflow and mnist handwriting data # Visualizing # Normalizing Data between 0,1 # Creating Models ## Flatting out the 2 dimensional tensors to 1 Dimension ##Hidden Layers with activation function RELU and size 16 ##Output Layer with activation softmax and size 10 for 10 digits recognition # Compiling the model to form neural network architecture defined ##Compiling Model with optimizer function ADAM , Loss function SPARSE CATEGORICAL CROSSENTROPY # Training Process: Model Trains ##Training Model # Evaluating models with test set ##Evaluating Model # Predicting # Retrieving most likely predicted Value using numpy ##Showing Handwritten digit image with prediction