无法理解如何解决我在打印命令时遇到的错误。
ACCURACY_THRESHOLD = 0.9
class myCallback(Callback):
def on_epoch_end(self, epoch, logs={}):
if epoch % 50 == 0:
print(" validation accuracy : %2.2f%% " %(logs.get('val_acc')*100))
print(" training accuracy : %2.2f%% " %(logs.get('acc')*100))
#model.save("/content/drive/My Drive/Colab Notebooks/model_A5.h5")
elif(logs.get('val_acc') > ACCURACY_THRESHOLD):
print("\nReached %2.2f%% validation accuracy, so stopping training ..." %(ACCURACY_THRESHOLD*100))
self.model.stop_training = True
#print("\n Val_acr = %2.2f%%" %(logs.get('val_acc')*100))
#print(" acr = %2.2f%%" %(logs.get('acc')*100))
callbacks = myCallback()
在您的情况下,logs.get('val_acc')
和logs.get('acc')
之一可能返回None
,如错误消息所提示。