diff --git a/example/main.ipynb b/example/main.ipynb index d5266f6..c97867c 100644 --- a/example/main.ipynb +++ b/example/main.ipynb @@ -181,8 +181,8 @@ "metadata": {}, "outputs": [], "source": [ - "np.savetxt(\"trans_mean.txt\",trans_mean)\n", - "np.savetxt(\"trans_std.txt\",trans_std)" + "np.savetxt(\"cache/trans_mean.txt\",trans_mean)\n", + "np.savetxt(\"cache/trans_std.txt\",trans_std)" ] }, { @@ -198,8 +198,8 @@ "metadata": {}, "outputs": [], "source": [ - "trans_mean = np.loadtxt(\"trans_mean.txt\")\n", - "trans_std = np.loadtxt(\"trans_std.txt\")" + "trans_mean = np.loadtxt(\"cache/trans_mean.txt\")\n", + "trans_std = np.loadtxt(\"cache/trans_std.txt\")" ] }, { @@ -312,8 +312,8 @@ "metadata": {}, "outputs": [], "source": [ - "trans_mean = np.loadtxt(\"trans_mean.txt\")\n", - "trans_std = np.loadtxt(\"trans_std.txt\")" + "trans_mean = np.loadtxt(\"cache/trans_mean.txt\")\n", + "trans_std = np.loadtxt(\"cache/trans_std.txt\")" ] }, { @@ -344,8 +344,8 @@ "metadata": {}, "outputs": [], "source": [ - "if not os.path.isdir(\"cache_params\"):\n", - " os.mkdir(\"cache_params\")" + "if not os.path.isdir(\"cache/cache_params\"):\n", + " os.mkdir(\"cache/cache_params\")" ] }, { @@ -399,7 +399,7 @@ " params_traj = ParamsTraj.fromPCA(data, data_desc.times, muh, varh_diag)\n", "\n", " # Export\n", - " params_traj.export(\"cache_params/%s.txt\" % ip3)" + " params_traj.export(\"cache/cache_params/%s.txt\" % ip3)" ] }, { @@ -436,7 +436,7 @@ " \"ip3_1p600\",\"ip3_1p700\",\"ip3_1p800\",\"ip3_1p900\",\"ip3_2p000\"]:\n", " \n", " # Import params traj\n", - " params_traj = ParamsTraj.fromFile(\"cache_params/%s.txt\" % ip3, nv=2, nh=1)\n", + " params_traj = ParamsTraj.fromFile(\"cache/cache_params/%s.txt\" % ip3, nv=2, nh=1)\n", "\n", " b0 = [x.b[0] for x in params_traj.params_traj]\n", "\n", @@ -456,8 +456,8 @@ "metadata": {}, "outputs": [], "source": [ - "if not os.path.isdir(\"cache_derivs\"):\n", - " os.mkdir(\"cache_derivs\")" + "if not os.path.isdir(\"cache/cache_derivs\"):\n", + " os.mkdir(\"cache/cache_derivs\")" ] }, { @@ -516,7 +516,7 @@ " print(\"IP3: \", ip3)\n", " \n", " # Import params traj\n", - " params_traj = ParamsTraj.fromFile(\"cache_params/%s.txt\" % ip3, nv=2, nh=1)\n", + " params_traj = ParamsTraj.fromFile(\"cache/cache_params/%s.txt\" % ip3, nv=2, nh=1)\n", " \n", " # Differentiate\n", " paramsTE_traj = params_traj.differentiate_with_TVR(\n", @@ -526,7 +526,7 @@ " )\n", " \n", " # Export\n", - " paramsTE_traj.export(\"cache_derivs/%s.txt\" % ip3)" + " paramsTE_traj.export(\"cache/cache_derivs/%s.txt\" % ip3)" ] }, { @@ -562,7 +562,7 @@ " \"ip3_1p100\",\"ip3_1p200\",\"ip3_1p300\",\"ip3_1p400\",\"ip3_1p500\",\n", " \"ip3_1p600\",\"ip3_1p700\",\"ip3_1p800\",\"ip3_1p900\",\"ip3_2p000\"]:\n", " # Import params TE traj\n", - " paramsTE_traj = ParamsTETraj.fromFile(\"cache_derivs/%s.txt\" % ip3, nv=2, nh=1)\n", + " paramsTE_traj = ParamsTETraj.fromFile(\"cache/cache_derivs/%s.txt\" % ip3, nv=2, nh=1)\n", " b0 = [x.b_TE[0] for x in paramsTE_traj.paramsTE_traj]\n", "\n", " # Plot\n", @@ -595,7 +595,7 @@ " \"ip3_1p100\",\"ip3_1p200\",\"ip3_1p300\",\"ip3_1p400\",\"ip3_1p500\",\n", " \"ip3_1p600\",\"ip3_1p700\",\"ip3_1p800\",\"ip3_1p900\",\"ip3_2p000\"]:\n", " # Import params TE traj\n", - " paramsTE_traj = ParamsTETraj.fromFile(\"cache_derivs/%s.txt\" % ip3, nv=2, nh=1)\n", + " paramsTE_traj = ParamsTETraj.fromFile(\"cache/cache_derivs/%s.txt\" % ip3, nv=2, nh=1)\n", " wt00 = [x.wt_TE[0,0] for x in paramsTE_traj.paramsTE_traj]\n", "\n", " # Plot\n", @@ -615,8 +615,8 @@ "metadata": {}, "outputs": [], "source": [ - "if not os.path.isdir(\"cache_filtered\"):\n", - " os.mkdir(\"cache_filtered\")" + "if not os.path.isdir(\"cache/cache_filtered\"):\n", + " os.mkdir(\"cache/cache_filtered\")" ] }, { @@ -631,8 +631,8 @@ " \"ip3_1p600\",\"ip3_1p700\",\"ip3_1p800\",\"ip3_1p900\",\"ip3_2p000\"]:\n", " \n", " # Import params and TE traj\n", - " params_traj = ParamsTraj.fromFile(\"cache_params/%s.txt\" % ip3, nv=2, nh=1)\n", - " paramsTE_traj = ParamsTETraj.fromFile(\"cache_derivs/%s.txt\" % ip3, nv=2, nh=1)\n", + " params_traj = ParamsTraj.fromFile(\"cache/cache_params/%s.txt\" % ip3, nv=2, nh=1)\n", + " paramsTE_traj = ParamsTETraj.fromFile(\"cache/cache_derivs/%s.txt\" % ip3, nv=2, nh=1)\n", " \n", " # Integrate\n", " no_steps = len(params_traj.params_traj) - 1\n", @@ -644,7 +644,7 @@ " )\n", " \n", " # Export\n", - " params_traj_filtered.export(\"cache_filtered/%s.txt\" % ip3)" + " params_traj_filtered.export(\"cache/cache_filtered/%s.txt\" % ip3)" ] }, { @@ -681,8 +681,8 @@ " \"ip3_1p600\",\"ip3_1p700\",\"ip3_1p800\",\"ip3_1p900\",\"ip3_2p000\"]:\n", " \n", " # Import params traj\n", - " params_traj_filtered = ParamsTraj.fromFile(\"cache_filtered/%s.txt\" % ip3, nv=2, nh=1)\n", - " params_traj = ParamsTraj.fromFile(\"cache_params/%s.txt\" % ip3, nv=2, nh=1)\n", + " params_traj_filtered = ParamsTraj.fromFile(\"cache/cache_filtered/%s.txt\" % ip3, nv=2, nh=1)\n", + " params_traj = ParamsTraj.fromFile(\"cache/cache_params/%s.txt\" % ip3, nv=2, nh=1)\n", " \n", " b0_filtered = [x.b[0] for x in params_traj_filtered.params_traj]\n", " b0 = [x.b[0] for x in params_traj.params_traj]\n", @@ -925,8 +925,8 @@ " print(\"IP3: \", ip3)\n", " \n", " # Import\n", - " params_traj = ParamsTraj.fromFile(\"cache_filtered/%s.txt\" % ip3, nv=2, nh=1)\n", - " paramsTE_traj = ParamsTETraj.fromFile(\"cache_derivs/%s.txt\" % ip3, nv=2, nh=1)\n", + " params_traj = ParamsTraj.fromFile(\"cache/cache_filtered/%s.txt\" % ip3, nv=2, nh=1)\n", + " paramsTE_traj = ParamsTETraj.fromFile(\"cache/cache_derivs/%s.txt\" % ip3, nv=2, nh=1)\n", " \n", " # Training data\n", " train_inputs0 = params_traj.get_tf_inputs_assuming_params0()\n", @@ -959,8 +959,8 @@ " print(\"IP3: \", ip3)\n", " \n", " # Import\n", - " params_traj = ParamsTraj.fromFile(\"cache_filtered/%s.txt\" % ip3, nv=2, nh=1)\n", - " paramsTE_traj = ParamsTETraj.fromFile(\"cache_derivs/%s.txt\" % ip3, nv=2, nh=1)\n", + " params_traj = ParamsTraj.fromFile(\"cache/cache_filtered/%s.txt\" % ip3, nv=2, nh=1)\n", + " paramsTE_traj = ParamsTETraj.fromFile(\"cache/cache_derivs/%s.txt\" % ip3, nv=2, nh=1)\n", " \n", " # Training data\n", " valid_inputs0 = params_traj.get_tf_inputs_assuming_params0()\n", @@ -1027,15 +1027,15 @@ ], "source": [ "# Save the output mean/std dev\n", - "with open(\"cache_outputs_mean.txt\",'wb') as f:\n", + "with open(\"cache/cache_outputs_mean.txt\",'wb') as f:\n", " pickle.dump(train_outputs_mean, f)\n", - "with open(\"cache_outputs_std_dev.txt\",'wb') as f:\n", + "with open(\"cache/cache_outputs_std_dev.txt\",'wb') as f:\n", " pickle.dump(train_outputs_std_dev, f)\n", "\n", "# Try to load\n", - "with open(\"cache_outputs_mean.txt\",'rb') as f:\n", + "with open(\"cache/cache_outputs_mean.txt\",'rb') as f:\n", " train_outputs_mean_check = pickle.load(f)\n", - "with open(\"cache_outputs_std_dev.txt\",'rb') as f:\n", + "with open(\"cache/cache_outputs_std_dev.txt\",'rb') as f:\n", " train_outputs_std_dev_check = pickle.load(f)\n", "\n", "print(train_outputs_mean, \" ; \", train_outputs_mean_check)\n", @@ -1286,7 +1286,7 @@ "tensorboard_callback = tf.keras.callbacks.TensorBoard(logdir, histogram_freq=1)\n", "\n", "val_checkpoint = tf.keras.callbacks.ModelCheckpoint(\n", - " 'trained_lowest_val', \n", + " 'trained/trained_lowest_val', \n", " monitor='val_loss', \n", " verbose=1,\n", " save_best_only=True, \n", @@ -1345,7 +1345,7 @@ ], "source": [ "# Save\n", - "model.save(\"trained\", save_traces=False)" + "model.save(\"trained/trained\", save_traces=False)" ] }, { @@ -1361,7 +1361,7 @@ "metadata": {}, "outputs": [], "source": [ - "model_trained = tf.keras.models.load_model(\"trained_lowest_val\")" + "model_trained = tf.keras.models.load_model(\"trained/trained_lowest_val\")" ] }, { @@ -1379,7 +1379,7 @@ } ], "source": [ - "params_traj = ParamsTraj.fromFile(\"cache_params/%s.txt\" % \"ip3_0p400\", nv=2, nh=1)\n", + "params_traj = ParamsTraj.fromFile(\"cache/cache_params/%s.txt\" % \"ip3_0p400\", nv=2, nh=1)\n", "int_input = params_traj.params_traj[0].get_tf_input_assuming_params0(tpt=0)\n", "print(int_input)\n", "int_output = model_trained(int_input)\n", @@ -1411,9 +1411,9 @@ ], "source": [ "# Load mean / std. dev. output normalization\n", - "with open(\"cache_outputs_mean.txt\",'rb') as f:\n", + "with open(\"cache/cache_outputs_mean.txt\",'rb') as f:\n", " train_outputs_mean = pickle.load(f)\n", - "with open(\"cache_outputs_std_dev.txt\",'rb') as f:\n", + "with open(\"cache/cache_outputs_std_dev.txt\",'rb') as f:\n", " train_outputs_std_dev = pickle.load(f)\n", "\n", "train_outputs_mean" @@ -1574,7 +1574,7 @@ } ], "source": [ - "params_traj = ParamsTraj.fromFile(\"cache_filtered/%s.txt\" % \"ip3_0p400\", nv=2, nh=1)\n", + "params_traj = ParamsTraj.fromFile(\"cache/cache_filtered/%s.txt\" % \"ip3_0p400\", nv=2, nh=1)\n", "params_start = params_traj.params_traj[0]\n", "\n", "params_traj_int = model_trained.integrate(\n",