Skip to content

Commit

Permalink
fixed filenames and paths
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver K. Ernst committed Jun 18, 2021
1 parent 16a5646 commit 84b97b6
Showing 1 changed file with 38 additions and 38 deletions.
76 changes: 38 additions & 38 deletions example/main.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
]
},
{
Expand All @@ -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\")"
]
},
{
Expand Down Expand Up @@ -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\")"
]
},
{
Expand Down Expand Up @@ -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\")"
]
},
{
Expand Down Expand Up @@ -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)"
]
},
{
Expand Down Expand Up @@ -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",
Expand All @@ -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\")"
]
},
{
Expand Down Expand Up @@ -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",
Expand All @@ -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)"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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\")"
]
},
{
Expand All @@ -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",
Expand All @@ -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)"
]
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -1345,7 +1345,7 @@
],
"source": [
"# Save\n",
"model.save(\"trained\", save_traces=False)"
"model.save(\"trained/trained\", save_traces=False)"
]
},
{
Expand All @@ -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\")"
]
},
{
Expand All @@ -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",
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 84b97b6

Please sign in to comment.