def test_unlabelled_classify(): if SUPERVISED == True: outfile = './results/gsn_sup_test_outputs.csv' with open("./results/gsn_sup_trained.pkl") as f: gsn = pickle.load(f) else: outfile = './results/gsn_ae_test_outputs.csv' with open("./results/gsn_ae_trained.pkl") as f: gsn = pickle.load(f) gsn = JointGSN.convert(gsn) gsn._corrupt_switch = False ds = MNIST(which_set='test',one_hot=True,all_labelled=ALL_LABELLED,supervised=SUPERVISED) mean = gsn._get_aggregate_classification(ds.X) am = np.argmax(mean, axis=1).astype(int) print 'am shape: ', am.shape test_output_file = open(outfile, "wb") writer = csv.writer(test_output_file, delimiter=',') writer.writerow(['Id', 'Prediction']) for idx, predict in enumerate(am): row = [idx+1, predict] writer.writerow(row) test_output_file.close()
def test_classify(): """ See how well a (supervised) GSN performs at classification. """ with open("gsn_sup_example.pkl") as f: gsn = pickle.load(f) gsn = JointGSN.convert(gsn) # turn off corruption gsn._corrupt_switch = False ds = MNIST(which_set='test', one_hot=True) mb_data = ds.X y = ds.y for i in xrange(1, 10): y_hat = gsn.classify(mb_data, trials=i) errors = np.abs(y_hat - y).sum() / 2.0 # error indices #np.sum(np.abs(y_hat - y), axis=1) != 0 print i, errors, errors / mb_data.shape[0]
def test_classify(): with open("./results/gsn_sup_trained.pkl") as f: gsn = pickle.load(f) gsn = JointGSN.convert(gsn) gsn._corrupt_switch = False ds = MNIST(which_set='test',one_hot=True,all_labelled=ALL_LABELLED,supervised=SUPERVISED) mb_data = ds.X y = ds.y outfile = open("./results/gsn_train_outputs.csv","wb") writer = csv.writer(outfile, delimiter=',', quotechar='"', quoting=csv.QUOTE_ALL) for i in xrange(1, 10): y_hat = gsn.classify(mb_data, trials=i) errors = np.abs(y_hat - y).sum() / 2.0 errors_normalize = errors / mb_data.shape[0] writer.writerow([i, errors, errors_normalize]) writer.writerow(y_hat) print i, errors, errors_normalize outfile.close()
def test_classify(): """ See how well a (supervised) GSN performs at classification. """ with open("gsn_sup_example.pkl") as f: gsn = pickle.load(f) gsn = JointGSN.convert(gsn) # turn off corruption gsn._corrupt_switch = False ds = MNIST(which_set='test') mb_data = ds.X y = ds.y for i in xrange(1, 10): y_hat = gsn.classify(mb_data, trials=i) errors = np.abs(y_hat - y).sum() / 2.0 # error indices #np.sum(np.abs(y_hat - y), axis=1) != 0 print(i, errors, errors / mb_data.shape[0])