Example #1
0
 if not failure:
     print("load cls_true success")
 failure, coords = load_lib.load_coords(keyword, directory)
 if not failure:
     print("load coords success")
 #----------------------------------------
 # test if the loading is successful or not
 print("### data number ###")
 print("length of training data set: {0}".format(len(data.train.images)))
 print("length of validation data set: {0}".format(
     len(data.validation.images)))
 print("length of test data set: {0}".format(len(data.test.images)))
 print("({0} | {1})\n".format(len(cls_pred), len(cls_true)))
 # confusion matrix
 print("### confusion matrix ###")
 failure, cm = load_lib.confusion_matrix(cls_true, cls_pred)
 if not failure:
     print("confusion matrix success")
 print(cm)
 # print data and the corresponding shuffle tracer of the first data
 print("### The first datum in dataset ###")
 print("data.test.images: {0}".format(data.test.images[0]))
 print("RA: {0}, DEC: {1}".format(coords.test[0][0], coords.test[0][1]))
 print("shuffle tracer: {0}".format(tracer.test[0]))
 print("true label: {0}".format(cls_true[0]))
 print("predict label: {0}".format(cls_pred[0]))
 # print data and the corresponding shuffle tracer of the last data
 print("### The final datum in dataset ###")
 print("data.test.images: {0}".format(data.test.images[-1]))
 print("RA: {0}, DEC: {1}".format(coords.test[-1][0], coords.test[-1][1]))
 print("shuffle tracer: {0}".format(tracer.test[-1]))
     "test_cls_true_source_sed_{0}.npy".format(keyword))
 # trace it back to the sorted list with tracers
 alice_sources_sorted = [
     value for _, value in sorted(zip(alice_cls_tracers, alice_sources))
 ]
 alice_cls_pred_sorted = [
     value for _, value in sorted(zip(alice_cls_tracers, alice_cls_pred))
 ]
 alice_cls_true_sorted = [
     value for _, value in sorted(zip(alice_cls_tracers, alice_cls_true))
 ]
 alice_sources_sorted = np.array(alice_sources_sorted)
 alice_cls_pred_sorted = np.array(alice_cls_pred_sorted)
 alice_cls_true_sorted = np.array(alice_cls_true_sorted)
 print("--- Confusion Matrix ---")
 failure, cm = confusion_matrix(alice_cls_true_sorted,
                                alice_cls_pred_sorted)
 print(cm)
 #-----------------------------------
 # load prediction 2
 print("### Prediction 2 ###")
 print("AI DIR = {0}".format(ai_bob))
 os.chdir(work_dir)
 os.chdir(ai_bob)
 bob_sources = np.load("test_set_source_sed_{0}.npy".format(keyword))
 bob_cls_pred = np.load("test_cls_pred_source_sed_{0}.npy".format(keyword))
 bob_cls_tracers = np.load("test_tracer_source_sed_{0}.npy".format(keyword))
 bob_cls_true = np.load("test_cls_true_source_sed_{0}.npy".format(keyword))
 # trace it back to the sorted list with tracers
 bob_sources_sorted = [
     value for _, value in sorted(zip(bob_cls_tracers, bob_sources))
 ]