From 80d3aab7f80d901435ba1aa08fe2c0f28a03683d Mon Sep 17 00:00:00 2001 From: glibesyck Date: Tue, 16 Jul 2024 09:21:52 +0300 Subject: [PATCH 1/3] cpu remove --- .../W1D2_ComparingTasks/W1D2_Tutorial1.ipynb | 155 ++++-------------- 1 file changed, 36 insertions(+), 119 deletions(-) diff --git a/tutorials/W1D2_ComparingTasks/W1D2_Tutorial1.ipynb b/tutorials/W1D2_ComparingTasks/W1D2_Tutorial1.ipynb index 7178cd8e5..7d2ce2d2b 100644 --- a/tutorials/W1D2_ComparingTasks/W1D2_Tutorial1.ipynb +++ b/tutorials/W1D2_ComparingTasks/W1D2_Tutorial1.ipynb @@ -49,8 +49,6 @@ "2. Train a network to accomplish these tasks and compare the performance of these networks.\n", "3. Measure how well different representations generalize\n", "\n", - "**Important note**: this tutorial leverages GPU acceleration. Using a GPU runtime in colab will make the the tutorial run 10x faster.\n", - "\n", "Let's get started.\n" ] }, @@ -59,7 +57,6 @@ "execution_count": null, "metadata": { "cellView": "form", - "execution": {}, "executionInfo": { "elapsed": 172, "status": "ok", @@ -107,7 +104,6 @@ "execution_count": null, "metadata": { "cellView": "form", - "execution": {}, "executionInfo": { "elapsed": 183983, "status": "ok", @@ -149,7 +145,6 @@ "execution_count": null, "metadata": { "cellView": "form", - "execution": {}, "executionInfo": { "elapsed": 5196, "status": "ok", @@ -202,8 +197,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -221,7 +215,6 @@ "execution_count": null, "metadata": { "cellView": "form", - "execution": {}, "executionInfo": { "elapsed": 187, "status": "ok", @@ -624,8 +617,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -655,8 +647,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -713,7 +704,6 @@ "execution_count": null, "metadata": { "cellView": "form", - "execution": {}, "executionInfo": { "elapsed": 2, "status": "ok", @@ -758,8 +748,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -815,8 +804,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -874,7 +862,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 3, "status": "ok", @@ -920,7 +907,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 4069, "status": "ok", @@ -992,7 +978,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 3195, "status": "ok", @@ -1047,7 +1032,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 7, "status": "ok", @@ -1096,7 +1080,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 6, "status": "ok", @@ -1156,7 +1139,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 6, "status": "ok", @@ -1207,7 +1189,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 7, "status": "ok", @@ -1239,7 +1220,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 6, "status": "ok", @@ -1275,8 +1255,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -1299,7 +1278,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 6, "status": "ok", @@ -1344,7 +1322,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 160722, "status": "ok", @@ -1396,8 +1373,8 @@ " for batch_idx, (X, y) in enumerate(sampled_val_loader):\n", " predictions = model(X)\n", " _, predicted_classes = torch.max(predictions, 1)\n", - " all_preds.extend(predicted_classes.cpu().numpy())\n", - " all_labels.extend(y.cpu().numpy())\n", + " all_preds.extend(predicted_classes.numpy())\n", + " all_labels.extend(y.numpy())\n", "\n", " #Compute confusion matrix\n", " conf_matrix = confusion_matrix(all_labels, all_preds)\n", @@ -1422,7 +1399,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 1975, "status": "ok", @@ -1475,9 +1451,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": {} - }, + "metadata": {}, "outputs": [], "source": [ "# to_remove explanation\n", @@ -1495,8 +1469,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -1527,7 +1500,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 4, "status": "ok", @@ -1570,15 +1542,13 @@ "\n", "- $N$ is the number of samples\n", "- $y_i$ is the true label for the $i^{th}$ sample, the number of on pixels\n", - "- $\\mu_i = \\text{CNN}(x_i)$ is the output of the model for the $i^{th}$ sample\n", - "- $f$ is the ReLU activation function" + "- $\\mu_i = \\text{CNN}(x_i)$ is the output of the model for the $i^{th}$ sample" ] }, { "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 4, "status": "ok", @@ -1609,7 +1579,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 4, "status": "ok", @@ -1635,8 +1604,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -1661,7 +1629,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 183, "status": "ok", @@ -1706,7 +1673,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 6, "status": "ok", @@ -1750,7 +1716,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 199703, "status": "ok", @@ -1813,7 +1778,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 2488, "status": "ok", @@ -1849,9 +1813,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": {} - }, + "metadata": {}, "outputs": [], "source": [ "#to_remove explanation\n", @@ -1866,8 +1828,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -1894,7 +1855,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 6, "status": "ok", @@ -1944,7 +1904,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 6, "status": "ok", @@ -1977,7 +1936,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 5, "status": "ok", @@ -2004,8 +1962,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -2028,7 +1985,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 5, "status": "ok", @@ -2071,7 +2027,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 168488, "status": "ok", @@ -2148,9 +2103,9 @@ " for batch_idx, (X, _) in enumerate(sampled_val_loader):\n", " if batch_idx == 0:\n", " outputs = model(X)\n", - " orig = X.cpu().numpy()\n", + " orig = X.numpy()\n", " original_images.extend(orig)\n", - " recon = outputs.cpu().numpy()\n", + " recon = outputs.numpy()\n", " reconstructed_images.extend(recon)\n", " plot_reconstructions(original_images, reconstructed_images, N_train_data, epochs_max_autoencoder)\n", " break\n", @@ -2184,7 +2139,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 1773, "status": "ok", @@ -2220,9 +2174,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": {} - }, + "metadata": {}, "outputs": [], "source": [ "#to_remove explanation\n", @@ -2239,8 +2191,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -2273,7 +2224,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 2, "status": "ok", @@ -2326,9 +2276,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": {} - }, + "metadata": {}, "outputs": [], "source": [ "plt.figure(figsize=(4, 2))\n", @@ -2375,7 +2323,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 4, "status": "ok", @@ -2417,7 +2364,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 64228, "status": "ok", @@ -2496,9 +2442,9 @@ " for batch_idx, (X, _) in enumerate(sampled_val_loader):\n", " if batch_idx == 0: # Only visualize the first batch for simplicity\n", " outputs = model(X)\n", - " orig = X.cpu().numpy()\n", + " orig = X.numpy()\n", " original_images.extend(orig)\n", - " recon = outputs.cpu().numpy()\n", + " recon = outputs.numpy()\n", " reconstructed_images.extend(recon)\n", " fig = plt.figure(figsize=(8, 4))\n", " rows, cols = 2, 6\n", @@ -2541,7 +2487,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 1019, "status": "ok", @@ -2576,9 +2521,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": {} - }, + "metadata": {}, "outputs": [], "source": [ "# to_remove explanation\n", @@ -2593,8 +2536,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -2641,7 +2583,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 2, "status": "ok", @@ -2734,7 +2675,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 0, "status": "ok", @@ -2785,7 +2725,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 72190, "status": "ok", @@ -2847,7 +2786,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 1484, "status": "ok", @@ -2904,9 +2842,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": {} - }, + "metadata": {}, "outputs": [], "source": [ "# to_remove explanation\n", @@ -2921,8 +2857,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -2952,7 +2887,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 0, "status": "ok", @@ -2993,7 +2927,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 72995, "status": "ok", @@ -3055,7 +2988,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "execution": {}, "executionInfo": { "elapsed": 1969, "status": "ok", @@ -3117,9 +3049,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": {} - }, + "metadata": {}, "outputs": [], "source": [ "# to_remove explanation\n", @@ -3133,8 +3063,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -3156,9 +3085,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": {} - }, + "metadata": {}, "outputs": [], "source": [ "MODEL_NAME_SOURCE = \"models/ConvNet_inpainting_10000_epoch_10.pth\"\n", @@ -3188,9 +3115,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": {} - }, + "metadata": {}, "outputs": [], "source": [ "set_seed(42)\n", @@ -3231,9 +3156,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": {} - }, + "metadata": {}, "outputs": [], "source": [ "# Create a single plot for all training costs with a logarithmic scale\n", @@ -3282,9 +3205,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": {} - }, + "metadata": {}, "outputs": [], "source": [ "# to_remove explanation\n", @@ -3302,8 +3223,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -3326,9 +3246,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "execution": {} - }, + "metadata": {}, "outputs": [], "source": [ "# to_remove explanation\n", @@ -3343,8 +3261,7 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form", - "execution": {} + "cellView": "form" }, "outputs": [], "source": [ @@ -3402,7 +3319,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.9.19" + "version": "3.11.5" } }, "nbformat": 4, From f517844ef6601b1f93bb7e71ae6d3a1588b25859 Mon Sep 17 00:00:00 2001 From: glibesyck Date: Tue, 16 Jul 2024 09:22:56 +0300 Subject: [PATCH 2/3] link upd --- projects/professional_development/mentorship_program.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/projects/professional_development/mentorship_program.md b/projects/professional_development/mentorship_program.md index cf9bb8851..d49641293 100644 --- a/projects/professional_development/mentorship_program.md +++ b/projects/professional_development/mentorship_program.md @@ -38,8 +38,5 @@ I’m a student, how can I make the most out of my mentoring experience? **Keep a respectful conversation**: mentoring is a social interaction. You may construct a long-lasting relationship with your mentor and your peers. Thus, be kind and have fun, as you’ll be discussing your dreams and career goals, as well as the efforts you’ve made so far to follow them. ---- - -# Find additional Professional Development resources through our website -https://neuromatch.io/resources/ +**Find additional Professional Development resources through [our website](https://neuromatch.io/resources/)** From 393934c671afcd56392d769e7a0b25e720ad7e9b Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 16 Jul 2024 06:40:05 +0000 Subject: [PATCH 3/3] Process tutorial notebooks --- .../W1D2_ComparingTasks/W1D2_Tutorial1.ipynb | 138 ++++++++++++++---- .../instructor/W1D2_Tutorial1.ipynb | 17 +-- .../student/W1D2_Tutorial1.ipynb | 17 +-- 3 files changed, 123 insertions(+), 49 deletions(-) diff --git a/tutorials/W1D2_ComparingTasks/W1D2_Tutorial1.ipynb b/tutorials/W1D2_ComparingTasks/W1D2_Tutorial1.ipynb index 7d2ce2d2b..d16874946 100644 --- a/tutorials/W1D2_ComparingTasks/W1D2_Tutorial1.ipynb +++ b/tutorials/W1D2_ComparingTasks/W1D2_Tutorial1.ipynb @@ -57,6 +57,7 @@ "execution_count": null, "metadata": { "cellView": "form", + "execution": {}, "executionInfo": { "elapsed": 172, "status": "ok", @@ -104,6 +105,7 @@ "execution_count": null, "metadata": { "cellView": "form", + "execution": {}, "executionInfo": { "elapsed": 183983, "status": "ok", @@ -145,6 +147,7 @@ "execution_count": null, "metadata": { "cellView": "form", + "execution": {}, "executionInfo": { "elapsed": 5196, "status": "ok", @@ -197,7 +200,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -215,6 +219,7 @@ "execution_count": null, "metadata": { "cellView": "form", + "execution": {}, "executionInfo": { "elapsed": 187, "status": "ok", @@ -617,7 +622,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -647,7 +653,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -704,6 +711,7 @@ "execution_count": null, "metadata": { "cellView": "form", + "execution": {}, "executionInfo": { "elapsed": 2, "status": "ok", @@ -748,7 +756,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -804,7 +813,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -862,6 +872,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 3, "status": "ok", @@ -907,6 +918,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 4069, "status": "ok", @@ -978,6 +990,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 3195, "status": "ok", @@ -1032,6 +1045,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 7, "status": "ok", @@ -1080,6 +1094,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 6, "status": "ok", @@ -1139,6 +1154,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 6, "status": "ok", @@ -1189,6 +1205,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 7, "status": "ok", @@ -1220,6 +1237,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 6, "status": "ok", @@ -1255,7 +1273,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -1278,6 +1297,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 6, "status": "ok", @@ -1322,6 +1342,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 160722, "status": "ok", @@ -1399,6 +1420,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 1975, "status": "ok", @@ -1451,7 +1473,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "execution": {} + }, "outputs": [], "source": [ "# to_remove explanation\n", @@ -1469,7 +1493,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -1500,6 +1525,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 4, "status": "ok", @@ -1549,6 +1575,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 4, "status": "ok", @@ -1579,6 +1606,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 4, "status": "ok", @@ -1604,7 +1632,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -1629,6 +1658,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 183, "status": "ok", @@ -1673,6 +1703,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 6, "status": "ok", @@ -1716,6 +1747,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 199703, "status": "ok", @@ -1778,6 +1810,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 2488, "status": "ok", @@ -1813,7 +1846,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "execution": {} + }, "outputs": [], "source": [ "#to_remove explanation\n", @@ -1828,7 +1863,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -1855,6 +1891,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 6, "status": "ok", @@ -1904,6 +1941,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 6, "status": "ok", @@ -1936,6 +1974,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 5, "status": "ok", @@ -1962,7 +2001,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -1985,6 +2025,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 5, "status": "ok", @@ -2027,6 +2068,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 168488, "status": "ok", @@ -2139,6 +2181,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 1773, "status": "ok", @@ -2174,7 +2217,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "execution": {} + }, "outputs": [], "source": [ "#to_remove explanation\n", @@ -2191,7 +2236,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -2224,6 +2270,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 2, "status": "ok", @@ -2276,7 +2323,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "execution": {} + }, "outputs": [], "source": [ "plt.figure(figsize=(4, 2))\n", @@ -2323,6 +2372,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 4, "status": "ok", @@ -2364,6 +2414,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 64228, "status": "ok", @@ -2487,6 +2538,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 1019, "status": "ok", @@ -2521,7 +2573,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "execution": {} + }, "outputs": [], "source": [ "# to_remove explanation\n", @@ -2536,7 +2590,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -2583,6 +2638,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 2, "status": "ok", @@ -2675,6 +2731,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 0, "status": "ok", @@ -2725,6 +2782,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 72190, "status": "ok", @@ -2786,6 +2844,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 1484, "status": "ok", @@ -2842,7 +2901,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "execution": {} + }, "outputs": [], "source": [ "# to_remove explanation\n", @@ -2857,7 +2918,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -2887,6 +2949,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 0, "status": "ok", @@ -2927,6 +2990,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 72995, "status": "ok", @@ -2988,6 +3052,7 @@ "cell_type": "code", "execution_count": null, "metadata": { + "execution": {}, "executionInfo": { "elapsed": 1969, "status": "ok", @@ -3049,7 +3114,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "execution": {} + }, "outputs": [], "source": [ "# to_remove explanation\n", @@ -3063,7 +3130,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -3085,7 +3153,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "execution": {} + }, "outputs": [], "source": [ "MODEL_NAME_SOURCE = \"models/ConvNet_inpainting_10000_epoch_10.pth\"\n", @@ -3115,7 +3185,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "execution": {} + }, "outputs": [], "source": [ "set_seed(42)\n", @@ -3156,7 +3228,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "execution": {} + }, "outputs": [], "source": [ "# Create a single plot for all training costs with a logarithmic scale\n", @@ -3205,7 +3279,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "execution": {} + }, "outputs": [], "source": [ "# to_remove explanation\n", @@ -3223,7 +3299,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -3246,7 +3323,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "execution": {} + }, "outputs": [], "source": [ "# to_remove explanation\n", @@ -3261,7 +3340,8 @@ "cell_type": "code", "execution_count": null, "metadata": { - "cellView": "form" + "cellView": "form", + "execution": {} }, "outputs": [], "source": [ @@ -3319,7 +3399,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.11.5" + "version": "3.9.19" } }, "nbformat": 4, diff --git a/tutorials/W1D2_ComparingTasks/instructor/W1D2_Tutorial1.ipynb b/tutorials/W1D2_ComparingTasks/instructor/W1D2_Tutorial1.ipynb index 6358c4939..5f1d99e38 100644 --- a/tutorials/W1D2_ComparingTasks/instructor/W1D2_Tutorial1.ipynb +++ b/tutorials/W1D2_ComparingTasks/instructor/W1D2_Tutorial1.ipynb @@ -49,8 +49,6 @@ "2. Train a network to accomplish these tasks and compare the performance of these networks.\n", "3. Measure how well different representations generalize\n", "\n", - "**Important note**: this tutorial leverages GPU acceleration. Using a GPU runtime in colab will make the the tutorial run 10x faster.\n", - "\n", "Let's get started.\n" ] }, @@ -1398,8 +1396,8 @@ " for batch_idx, (X, y) in enumerate(sampled_val_loader):\n", " predictions = model(X)\n", " _, predicted_classes = torch.max(predictions, 1)\n", - " all_preds.extend(predicted_classes.cpu().numpy())\n", - " all_labels.extend(y.cpu().numpy())\n", + " all_preds.extend(predicted_classes.numpy())\n", + " all_labels.extend(y.numpy())\n", "\n", " #Compute confusion matrix\n", " conf_matrix = confusion_matrix(all_labels, all_preds)\n", @@ -1572,8 +1570,7 @@ "\n", "- $N$ is the number of samples\n", "- $y_i$ is the true label for the $i^{th}$ sample, the number of on pixels\n", - "- $\\mu_i = \\text{CNN}(x_i)$ is the output of the model for the $i^{th}$ sample\n", - "- $f$ is the ReLU activation function" + "- $\\mu_i = \\text{CNN}(x_i)$ is the output of the model for the $i^{th}$ sample" ] }, { @@ -2154,9 +2151,9 @@ " for batch_idx, (X, _) in enumerate(sampled_val_loader):\n", " if batch_idx == 0:\n", " outputs = model(X)\n", - " orig = X.cpu().numpy()\n", + " orig = X.numpy()\n", " original_images.extend(orig)\n", - " recon = outputs.cpu().numpy()\n", + " recon = outputs.numpy()\n", " reconstructed_images.extend(recon)\n", " plot_reconstructions(original_images, reconstructed_images, N_train_data, epochs_max_autoencoder)\n", " break\n", @@ -2502,9 +2499,9 @@ " for batch_idx, (X, _) in enumerate(sampled_val_loader):\n", " if batch_idx == 0: # Only visualize the first batch for simplicity\n", " outputs = model(X)\n", - " orig = X.cpu().numpy()\n", + " orig = X.numpy()\n", " original_images.extend(orig)\n", - " recon = outputs.cpu().numpy()\n", + " recon = outputs.numpy()\n", " reconstructed_images.extend(recon)\n", " fig = plt.figure(figsize=(8, 4))\n", " rows, cols = 2, 6\n", diff --git a/tutorials/W1D2_ComparingTasks/student/W1D2_Tutorial1.ipynb b/tutorials/W1D2_ComparingTasks/student/W1D2_Tutorial1.ipynb index 809914711..990f65aad 100644 --- a/tutorials/W1D2_ComparingTasks/student/W1D2_Tutorial1.ipynb +++ b/tutorials/W1D2_ComparingTasks/student/W1D2_Tutorial1.ipynb @@ -49,8 +49,6 @@ "2. Train a network to accomplish these tasks and compare the performance of these networks.\n", "3. Measure how well different representations generalize\n", "\n", - "**Important note**: this tutorial leverages GPU acceleration. Using a GPU runtime in colab will make the the tutorial run 10x faster.\n", - "\n", "Let's get started.\n" ] }, @@ -1390,8 +1388,8 @@ " for batch_idx, (X, y) in enumerate(sampled_val_loader):\n", " predictions = model(X)\n", " _, predicted_classes = torch.max(predictions, 1)\n", - " all_preds.extend(predicted_classes.cpu().numpy())\n", - " all_labels.extend(y.cpu().numpy())\n", + " all_preds.extend(predicted_classes.numpy())\n", + " all_labels.extend(y.numpy())\n", "\n", " #Compute confusion matrix\n", " conf_matrix = confusion_matrix(all_labels, all_preds)\n", @@ -1556,8 +1554,7 @@ "\n", "- $N$ is the number of samples\n", "- $y_i$ is the true label for the $i^{th}$ sample, the number of on pixels\n", - "- $\\mu_i = \\text{CNN}(x_i)$ is the output of the model for the $i^{th}$ sample\n", - "- $f$ is the ReLU activation function" + "- $\\mu_i = \\text{CNN}(x_i)$ is the output of the model for the $i^{th}$ sample" ] }, { @@ -2118,9 +2115,9 @@ " for batch_idx, (X, _) in enumerate(sampled_val_loader):\n", " if batch_idx == 0:\n", " outputs = model(X)\n", - " orig = X.cpu().numpy()\n", + " orig = X.numpy()\n", " original_images.extend(orig)\n", - " recon = outputs.cpu().numpy()\n", + " recon = outputs.numpy()\n", " reconstructed_images.extend(recon)\n", " plot_reconstructions(original_images, reconstructed_images, N_train_data, epochs_max_autoencoder)\n", " break\n", @@ -2459,9 +2456,9 @@ " for batch_idx, (X, _) in enumerate(sampled_val_loader):\n", " if batch_idx == 0: # Only visualize the first batch for simplicity\n", " outputs = model(X)\n", - " orig = X.cpu().numpy()\n", + " orig = X.numpy()\n", " original_images.extend(orig)\n", - " recon = outputs.cpu().numpy()\n", + " recon = outputs.numpy()\n", " reconstructed_images.extend(recon)\n", " fig = plt.figure(figsize=(8, 4))\n", " rows, cols = 2, 6\n",