from dagbldr.datasets import fetch_fer from dagbldr.utils import convert_to_one_hot from dagbldr.utils import load_checkpoint, interpolate_between_points, make_gif parser = argparse.ArgumentParser() parser.add_argument("saved_functions_file", help="Saved pickle file from vae training") parser.add_argument("--seed", "-s", help="random seed for path calculation", action="store", default=1979, type=int) args = parser.parse_args() if not os.path.exists(args.saved_functions_file): raise ValueError("Please provide a valid path for saved pickle file!") checkpoint_dict = load_checkpoint(args.saved_functions_file) encode_function = checkpoint_dict["encode_function"] decode_function = checkpoint_dict["decode_function"] predict_function = checkpoint_dict["predict_function"] fer = fetch_fer() data = fer["data"] valid_indices = fer["valid_indices"] valid_data = data[valid_indices] mean_norm = fer["mean0"] pca_tf = fer["pca_matrix"] X = valid_data - mean_norm X = np.dot(X, pca_tf.T) y = fer["target"][valid_indices] n_classes = len(set(y)) random_state = np.random.RandomState(args.seed)
t = time.time() else: t = index plt.savefig("lines_%i.png" % t) def delta(x): return np.hstack((x[1:, 0][:, None], x[1:, 1:] - x[:-1, 1:])) def undelta(x): agg = np.cumsum(x[:, 1:], axis=0) return np.hstack((x[:, 0][:, None], agg)) model_path = sys.argv[1] checkpoint = load_checkpoint(model_path) predict_function = checkpoint.checkpoint_dict["predict_function"] cost_function = checkpoint.checkpoint_dict["cost_function"] iamondb = fetch_iamondb() X = iamondb["data"] X_offset = [delta(x) for x in X] X = X_offset Xt = [x[:, 1:] for x in X] X_len = np.array([len(x) for x in Xt]).sum() X_mean = np.array([x.sum() for x in Xt]).sum() / X_len X_sqr = np.array([(x**2).sum() for x in Xt]).sum() / X_len X_std = np.sqrt(X_sqr - X_mean ** 2) def normalize(x):
else: t = index plt.savefig("lines_%i.png" % t) def delta(x): return np.hstack((x[1:, 0][:, None], x[1:, 1:] - x[:-1, 1:])) def undelta(x): agg = np.cumsum(x[:, 1:], axis=0) return np.hstack((x[:, 0][:, None], agg)) model_path = sys.argv[1] checkpoint = load_checkpoint(model_path) predict_function = checkpoint.checkpoint_dict["predict_function"] cost_function = checkpoint.checkpoint_dict["cost_function"] iamondb = fetch_iamondb() X = iamondb["data"] X_offset = [delta(x) for x in X] X = X_offset Xt = [x[:, 1:] for x in X] X_len = np.array([len(x) for x in Xt]).sum() X_mean = np.array([x.sum() for x in Xt]).sum() / X_len X_sqr = np.array([(x**2).sum() for x in Xt]).sum() / X_len X_std = np.sqrt(X_sqr - X_mean**2) def normalize(x):