Python错误:*不支持的操作数类型:'None Type'和'int'

问题描述 投票:0回答:1

无法理解如何解决我在打印命令时遇到的错误。

 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()
python machine-learning callback operands
1个回答
0
投票

在您的情况下,logs.get('val_acc')logs.get('acc')之一可能返回None,如错误消息所提示。

© www.soinside.com 2019 - 2024. All rights reserved.