diff options
author | Vasil Zlatanov <v@skozl.com> | 2018-11-20 15:37:40 +0000 |
---|---|---|
committer | Vasil Zlatanov <v@skozl.com> | 2018-11-20 15:37:40 +0000 |
commit | 933b375859125bdb1609c5e86afc248d70203ada (patch) | |
tree | 32931d30e95ec6bbc39c9f7d4008bb3f238ffd6c | |
parent | 042f56da4b930f8ed15e763011b7b19cb3fd517f (diff) | |
download | vz215_np1915-933b375859125bdb1609c5e86afc248d70203ada.tar.gz vz215_np1915-933b375859125bdb1609c5e86afc248d70203ada.tar.bz2 vz215_np1915-933b375859125bdb1609c5e86afc248d70203ada.zip |
Split up long lines
-rwxr-xr-x | train.py | 15 |
1 files changed, 10 insertions, 5 deletions
@@ -126,7 +126,8 @@ def test_model(M, faces_train, faces_test, target_train, target_test, args): faces_train = np.dot(faces_train, e_vecs.T) faces_test = np.dot(faces_test, e_vecs.T) - rec_vecs = np.add(np.tile(average_face, (faces_test.shape[0], 1)), np.dot(faces_test, e_vecs) * deviations_tr) + rec_vecs = np.add(np.tile(average_face, + (faces_test.shape[0], 1)), np.dot(faces_test, e_vecs) * deviations_tr) distances = LA.norm(raw_faces_test - rec_vecs, axis=1); if args.reconstruct: @@ -211,7 +212,8 @@ def main(): parser.add_argument("-t", "--split", help="Fractoin of data to use for testing", type=float, default=0.3) ### best split for lda = 22 ### best plit for pca = 20 - parser.add_argument("-2", "--grapheigen", help="Swow 2D graph of targets versus principal components", action='store_true') + parser.add_argument("-2", "--grapheigen", help="Swow 2D graph of targets versus principal components", + action='store_true') parser.add_argument("-p", "--pca", help="Use PCA", action='store_true') parser.add_argument("-l", "--lda", help="Use LDA", action='store_true') parser.add_argument("-r", "--reconstruct", help="Use PCA reconstruction, specify face NR", type=int, default=0) @@ -248,7 +250,8 @@ def main(): distances = np.zeros((n_faces, faces_test.shape[0])) for i in range(n_faces): - target_pred, distances[i] = test_model(args.eigen, faces_train[i], faces_test, target_train[i], target_test, args) + target_pred, distances[i] = test_model(args.eigen, faces_train[i], + faces_test, target_train[i], target_test, args) target_pred = np.argmin(distances, axis=0) elif args.reigen: target_pred = np.zeros((args.reigen-args.eigen, target_test.shape[0])) @@ -257,7 +260,8 @@ def main(): for M in range(args.eigen, args.reigen): start = timer() - target_pred[M - args.eigen], rec_error[M - args.eigen] = test_model(M, faces_train, faces_test, target_train, target_test, args) + target_pred[M - args.eigen], rec_error[M - args.eigen] = test_model(M, faces_train, + faces_test, target_train, target_test, args) end = timer() print("Run with", M, "eigenvalues completed in ", end-start, "seconds") print("Memory Used:", psutil.Process(os.getpid()).memory_info().rss) @@ -273,7 +277,8 @@ def main(): rec_error = np.zeros((args.ensemble, n_faces, faces_test.shape[0])) target_pred = np.zeros((args.ensemble, target_test.shape[0])) for i in range(args.ensemble): - target_pred[i], rec_error[i] = test_model(args.eigen, faces_train_ens[i], faces_test, target_train, target_test, args) + target_pred[i], rec_error[i] = test_model(args.eigen, faces_train_ens[i], + faces_test, target_train, target_test, args) target_pred_comb = np.zeros(target_pred.shape[1]) target_pred = target_pred.astype(int).T |