lmoroney/dlaicourse

Exercise2-Answer.ipynb: it should get acc instead of accuracy

yohei1126 opened this issue · 2 comments

class myCallback(tf.keras.callbacks.Callback):
  def on_epoch_end(self, epoch, logs={}):
    if(logs.get('accuracy')>0.6):
      print("\nReached 60% accuracy so cancelling training!")
      self.model.stop_training = True

This does not work. logs.get('accuracy') always returns None.
It should be

class myCallback(tf.keras.callbacks.Callback):
  def on_epoch_end(self, epoch, logs={}):
    if(logs.get('acc')>0.6):
      print("\nReached 60% accuracy so cancelling training!")
      self.model.stop_training = True

Yes, I had a sames result.
logs.get('accuracy') made error but logs.get('acc') is ok.

This is because of Tensorflow 1. If you upgrade it to Tensorflow 2, 'accuracy' should work.