Commit b7f5f30d authored by Dasun Madushanka's avatar Dasun Madushanka

Update bcpModel_Sequetail.py

parent 1f24a8f0
......@@ -4,8 +4,11 @@
# In[13]:
#add the tensorflow package
import tensorflow as tf
#assign values to parameters
mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
......@@ -13,6 +16,8 @@ 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)
#convential neural network archtecture
#change the parameters- add4 sequentail layers and chenge epochs to 40
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Flatten())
model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))
......@@ -20,12 +25,12 @@ model.add(tf.keras.layers.Dense(128, activation=tf.nn.relu))
model.add(tf.keras.layers.Dense(10, activation=tf.nn.softmax))
model.compile(optimizer='adam',loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(x_train, y_train, epochs=3)
model.fit(x_train, y_train, epochs=40)
# In[14]:
#genrare accuracy level
val_loss, val_acc = model.evaluate(x_test, y_test)
print(val_loss,val_acc)
......@@ -34,7 +39,7 @@ print(val_loss,val_acc)
# In[11]:
#view plot diagram
import matplotlib.pyplot as plt
......@@ -45,7 +50,7 @@ print(x_train[0])
# In[36]:
#save the model
model.save("num_reader.model")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment