Beispiel #1
0
    dt_string,
    predicted_lenses_filepath='../Results/g_r_%s/PredictedAll' % dt_string)

savePredictedLenses(
    all_des_names,
    all_predicted_class_probabilities,
    predicted_lenses_filepath='../Results/g_r_%s/PredictedAll' % dt_string,
    text_file_path='../Results/g_r_%s/Predicted84/All_LensesPredicted.txt' %
    dt_string)

excel_headers.append("Predicted_Lens_All")
excel_dictionary.append(all_lens_predicted_count)
excel_headers.append("Predicted_No_Lens_All")
excel_dictionary.append(all_non_lens_predicted_count)

# K fold for training data
executeKFoldValidation(training_data, training_labels, val_data, val_labels,
                       testing_data, testing_labels, images_47, labels_47,
                       images_84, labels_84, all_unseen_images,
                       all_unseen_labels)

print("Test loss of normal CNN: %s" % scores[0])
print("Test accuracy of normal CNN: %s" % (scores[1] * 100))

# add row to excel table
if makeNewCSVFile:
    createExcelSheet('../Results/new_kerasCNN_Results.csv', excel_headers)
    writeToFile('../Results/new_kerasCNN_Results.csv', excel_dictionary)
else:
    writeToFile('../Results/new_kerasCNN_Results.csv', excel_dictionary)
    text_file_path=
    '../Results/%s/UnseenKnownLenses/PredictedMatrixBeforeKFOLD.txt' %
    dt_string,
    predicted_lenses_filepath='../Results/%s/UnseenKnownLenses' % dt_string)

predicted_lenses, predicted_no_lenses = savePredictedLenses(
    known_des_names,
    predicted_class_probabilities_known_lenses,
    text_file_path='../Results/%s/UnseenKnownLenses/'
    'PredictedMatrixBeforeKFOLD.txt' % dt_string,
    predicted_lenses_filepath='../Results/%s/UnseenKnownLenses' % dt_string)

excel_headers.append("Unseen_Known_Lenses_Predicted")
excel_dictionary.append(lens_predicted)
excel_headers.append("Unseen_Known_Lenses_No_Lens_Predicted")
excel_dictionary.append(non_lens_predicted)

# K fold for training data
executeKFoldValidation(training_data, training_labels, val_data, val_labels,
                       testing_data, testing_labels, known_images,
                       known_labels, known_des_names)

if makeNewCSVFile:
    createExcelSheet('../Results/Architecture_kerasCNN_Results.csv',
                     excel_headers)
    writeToFile('../Results/Architecture_kerasCNN_Results.csv',
                excel_dictionary)
else:
    writeToFile('../Results/Architecture_kerasCNN_Results.csv',
                excel_dictionary)