Skip to content

Commit dbd56af

Browse files
authored
Merge pull request #148 from aamini/2024
2024 day 1
2 parents 2ed6465 + 840befc commit dbd56af

16 files changed

+2280
-749
lines changed

lab1/Part1_TensorFlow.ipynb

Lines changed: 103 additions & 94 deletions
Large diffs are not rendered by default.

lab1/Part2_Music_Generation.ipynb

Lines changed: 243 additions & 160 deletions
Large diffs are not rendered by default.

lab1/solutions/Part1_TensorFlow_Solution.ipynb

Lines changed: 114 additions & 96 deletions
Large diffs are not rendered by default.

lab1/solutions/Part2_Music_Generation_Solution.ipynb

Lines changed: 247 additions & 161 deletions
Large diffs are not rendered by default.

lab2/Part1_MNIST.ipynb

Lines changed: 106 additions & 88 deletions
Large diffs are not rendered by default.

lab2/Part2_FaceDetection.ipynb

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,15 @@
8585
"import numpy as np\n",
8686
"from tqdm import tqdm\n",
8787
"\n",
88-
"\n",
8988
"# Download and import the MIT Introduction to Deep Learning package\n",
9089
"!pip install mitdeeplearning\n",
91-
"import mitdeeplearning as mdl"
90+
"import mitdeeplearning as mdl\n",
91+
"\n",
92+
"# Import Comet\n",
93+
"!pip install comet_ml\n",
94+
"import comet_ml\n",
95+
"comet_ml.init(project_name=\"6.s191lab2_part2_CNN\")\n",
96+
"comet_model_1 = comet_ml.Experiment()"
9297
]
9398
},
9499
{
@@ -179,7 +184,8 @@
179184
"\n",
180185
"plt.subplot(1, 2, 2)\n",
181186
"plt.imshow(not_face_images[idx_not_face])\n",
182-
"plt.title(\"Not Face\"); plt.grid(False)"
187+
"plt.title(\"Not Face\"); plt.grid(False)\n",
188+
"comet_model_1.log_figure(figure=plt)"
183189
]
184190
},
185191
{
@@ -300,9 +306,13 @@
300306
" x, y = loader.get_batch(batch_size)\n",
301307
" loss = standard_train_step(x, y)\n",
302308
"\n",
309+
" comet_model_1.log_metric(\"loss\", loss.numpy().mean(), idx)\n",
303310
" # Record the loss and plot the evolution of the loss as a function of training\n",
304311
" loss_history.append(loss.numpy().mean())\n",
305-
" plotter.plot(loss_history.get())"
312+
" plotter.plot(loss_history.get())\n",
313+
"\n",
314+
"comet_model_1.log_figure(figure=plt)\n",
315+
"comet_model_1.end()"
306316
]
307317
},
308318
{
@@ -756,6 +766,9 @@
756766
"source": [
757767
"### Training the SS-VAE ###\n",
758768
"\n",
769+
"comet_ml.init(project_name=\"6.s191lab2_part2_VAE\")\n",
770+
"comet_model_2 = comet_ml.Experiment()\n",
771+
"\n",
759772
"# Hyperparameters\n",
760773
"batch_size = 32\n",
761774
"learning_rate = 5e-4\n",
@@ -806,6 +819,7 @@
806819
" (x, y) = loader.get_batch(batch_size)\n",
807820
" # loss optimization\n",
808821
" loss = ss_vae_train_step(x, y)\n",
822+
" comet_model_2.log_metric(\"loss\", loss, step=j)\n",
809823
" \n",
810824
" # plot the progress every 200 steps\n",
811825
" if j % 500 == 0: \n",
@@ -884,7 +898,9 @@
884898
"\n",
885899
"ax[1].imshow(mdl.util.create_grid_of_images(x[ind[-25:]]))\n",
886900
"ax[1].set_title(\"Samples with the highest reconstruction loss \\n\" + \n",
887-
" f\"Average recon loss: {np.mean(vae_loss[ind[-25:]]):.2f}\");"
901+
" f\"Average recon loss: {np.mean(vae_loss[ind[-25:]]):.2f}\");\n",
902+
"\n",
903+
"comet_model_2.log_figure()"
888904
]
889905
},
890906
{
@@ -950,7 +966,9 @@
950966
"# Visualize all of the reconstructions!\n",
951967
"ax[1].imshow(mdl.util.create_grid_of_images(recons, (1, num_steps)))\n",
952968
"ax[1].set_xlabel(\"Latent step\")\n",
953-
"ax[1].set_ylabel(\"Visualization\");\n"
969+
"ax[1].set_ylabel(\"Visualization\");\n",
970+
"\n",
971+
"comet_model_2.log_figure()"
954972
]
955973
},
956974
{
@@ -999,7 +1017,10 @@
9991017
"# Plot the results\n",
10001018
"plt.plot(np.linspace(np.min(z_mean), np.max(z_mean), num_steps+1), accuracy_per_latent,'-o')\n",
10011019
"plt.xlabel(\"Latent step\")\n",
1002-
"plt.ylabel(\"Relative accuracy\")"
1020+
"plt.ylabel(\"Relative accuracy\")\n",
1021+
"\n",
1022+
"comet_model_2.log_figure()\n",
1023+
"comet_model_2.end()"
10031024
]
10041025
},
10051026
{

0 commit comments

Comments
 (0)