lmoroney / dlaicourse

Notebooks for learning deep learning
5.66k stars 5.36k forks source link

TF 2.0 compatibility - callbacks #29

Open erkandiken opened 5 years ago

erkandiken commented 5 years ago

The following code does not work with TF 2.0:

accuracy = logs.get('acc')

instead, the following code should be used.

accuracy = logs.get('accuracy')

Complete working example code:

def on_epoch_end(self, epoch, logs={}):
        acc_threshold = 0.99
        accuracy = logs.get('accuracy')
        if accuracy > acc_threshold:
            print('\nReached {0} % accuracy so cancelling training!\n'.format(acc_threshold))
            self.model.stop_training = True
tonicava commented 5 years ago

that's right!