Skip to content

Instantly share code, notes, and snippets.

View a46554's full-sized avatar

RayTsai_tw a46554

View GitHub Profile
Epoch 1/15
1875/1875 [==============================] - 3s 2ms/step - loss: 0.2570 - accuracy: 0.9265
Epoch 2/15
1875/1875 [==============================] - 4s 2ms/step - loss: 0.1133 - accuracy: 0.9667
Epoch 3/15
1875/1875 [==============================] - 3s 2ms/step - loss: 0.0778 - accuracy: 0.9765
Epoch 4/15
1875/1875 [==============================] - 3s 2ms/step - loss: 0.0580 - accuracy: 0.9822
Epoch 5/15
1875/1875 [==============================] - 3s 2ms/step - loss: 0.0444 - accuracy: 0.9859
import tensorflow as tf
# Callback function to check model accuracy
class RayCallback(tf.keras.callbacks.Callback):
def on_epoch_end(self, epoch, logs={}):
if(logs.get('accuracy')>0.998):
print("\nReached 99.8% accuracy so cancelling training!")
self.model.stop_training = True
# Load the MNIST handwrite digit data set