Error:
Def classification_accuracy (Q, data_loader) :
Q.e val ()
Labels=[]
Scores=[]
Main function:
If __name__=="__main__ ':
Train_loader valid_loader, test_loader=load_data ()
Best_model='best_DNN_model. PKL'
If not OS. Path. The exists (OS) path) join (folder, best_model)) :
Fc_dnn=generate_model (train_loader valid_loader)
Save_model (fc_dnn, OS. Path. Join (folder, best_model))
The else:
Fc_dnn=load_model (OS) path) join (folder, best_model))
Test_loss test_acc, test_auc=classification_accuracy (fc_dnn test_loader)
Print ()
Print (' Test loss {: 4}, acc {: 4}, auc {: 4} '. The format (float (test_loss), float (test_acc), float (test_auc)))
Probas1, y=get_result_from_model (fc_dnn test_loader)
Average_precision=average_precision_score (y, probas1)
Print (' Test aupr {: 4} '. The format (average_precision))
FPR, TPR, thresholds=roc_curve (y, probas1 pos_label=1)
Roc_auc=auc (FPR, TPR)
Print (' Test auc {: 4} '. The format (roc_auc))
Write_result (probas1, y)
print('Done')
CodePudding user response:
Fc_dnn always null value?That you want to debug to see fc_dnn=generate_model (train_loader, valid_loader) or fc_dnn here=load_model (OS) path) join (folder, best_model))