Skip to content

Commit

Permalink
fixing accuracy
Browse files Browse the repository at this point in the history
  • Loading branch information
namannarula committed May 22, 2021
1 parent 224ff2f commit d9895ab
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions RockPaperScissors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import tensorflow_datasets as tfds
import matplotlib.pyplot as plt
import numpy as np
import tensorflowjs as tfjs

DATASET_NAME = 'rock_paper_scissors'

Expand Down Expand Up @@ -243,10 +244,10 @@ def augment_data(image, label):

#Defining Callbacks

DESIRED_ACCURACY = 0.90
DESIRED_ACCURACY = 0.92
class myCallback(tf.keras.callbacks.Callback):
def on_epoch_end(self, epoch, logs={}):
if(logs.get('accuracy') is not None and logs.get('accuracy') >= DESIRED_ACCURACY):
if(logs.get('val_accuracy') is not None and logs.get('val_accuracy') >= DESIRED_ACCURACY):
print("\nReached 90% accuracy so cancelling training!!")
self.model.stop_training = True

Expand Down Expand Up @@ -302,4 +303,6 @@ def render_training_history(training_history):

render_training_history(training_history)

tfjs.converters.save_keras_model(model, "rock-paper-scissors-js")

model.save("rock-paper-scissors-trained.h5")

0 comments on commit d9895ab

Please sign in to comment.