From 5030bf03145501d553fc08ffae415a7af6718cc1 Mon Sep 17 00:00:00 2001 From: Anna Foix Date: Sun, 25 Aug 2024 19:24:37 +0100 Subject: [PATCH 1/2] remove the Machine learning introduction course sentence --- solution.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solution.py b/solution.py index 49a3567..ba8ce55 100644 --- a/solution.py +++ b/solution.py @@ -514,7 +514,7 @@ def predict(model, dataset): # %% [markdown] -# Now we call the predict method with the clean and tainted models on the clean and tainted datasets. +# Now we call the predict function with the clean and tainted models on the clean and tainted datasets. # %% pred_clean_clean, true_labels = predict(model_clean, test_dataset) @@ -523,7 +523,7 @@ def predict(model, dataset): pred_tainted_tainted, _ = predict(model_tainted, tainted_test_dataset) # %% [markdown] -# We can investigate the results using the confusion matrix, which you should recall from the Introduction to Machine Learning exercise. The function in the cell below will create a nicely annotated confusion matrix. +# We can investigate the results using the confusion matrix, you can read more about them [here](https://en.wikipedia.org/wiki/Confusion_matrix). The function in the cell below will create a nicely annotated confusion matrix. # %% from sklearn.metrics import confusion_matrix From 41997c2b75de91f904b4127a1b64ccfcea8c606a Mon Sep 17 00:00:00 2001 From: afoix Date: Sun, 25 Aug 2024 18:25:08 +0000 Subject: [PATCH 2/2] Commit from GitHub Actions (Build Notebooks) --- exercise.ipynb | 240 ++++++++++++++++++------------------- solution.ipynb | 316 ++++++++++++++++++++++++------------------------- 2 files changed, 278 insertions(+), 278 deletions(-) diff --git a/exercise.ipynb b/exercise.ipynb index 9d46637..062810a 100644 --- a/exercise.ipynb +++ b/exercise.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "055f5871", + "id": "b914acba", "metadata": {}, "source": [ "# Exercise 7: Failure Modes And Limits of Deep Learning" @@ -10,7 +10,7 @@ }, { "cell_type": "markdown", - "id": "327d7b71", + "id": "6c1c3a9b", "metadata": {}, "source": [ "In the following exercise, we explore the failure modes and limits of neural networks.\n", @@ -23,7 +23,7 @@ }, { "cell_type": "markdown", - "id": "41654ae2", + "id": "2e85adb6", "metadata": {}, "source": [ "\n", @@ -44,7 +44,7 @@ }, { "cell_type": "markdown", - "id": "0a64a471", + "id": "a43fe7eb", "metadata": {}, "source": [ "### Acknowledgements\n", @@ -53,7 +53,7 @@ }, { "cell_type": "markdown", - "id": "b5bcabb9", + "id": "4683adbf", "metadata": {}, "source": [ "### Data Loading\n", @@ -67,7 +67,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9d41afcb", + "id": "fdb18bd2", "metadata": {}, "outputs": [], "source": [ @@ -90,7 +90,7 @@ }, { "cell_type": "markdown", - "id": "1d04380a", + "id": "9a5490e9", "metadata": {}, "source": [ "### Part 1: Preparation of a Tainted Dataset\n", @@ -101,7 +101,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9b0b1a97", + "id": "23e03cf0", "metadata": {}, "outputs": [], "source": [ @@ -115,7 +115,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4d83f1a2", + "id": "b0f72652", "metadata": {}, "outputs": [], "source": [ @@ -126,7 +126,7 @@ }, { "cell_type": "markdown", - "id": "12b9d7af", + "id": "e055a001", "metadata": {}, "source": [ "## Part 1.1: Local Corruption of Data\n", @@ -137,7 +137,7 @@ { "cell_type": "code", "execution_count": null, - "id": "022103f5", + "id": "a12a3a3f", "metadata": {}, "outputs": [], "source": [ @@ -149,7 +149,7 @@ { "cell_type": "code", "execution_count": null, - "id": "64ea44e2", + "id": "3de5e726", "metadata": {}, "outputs": [], "source": [ @@ -172,7 +172,7 @@ }, { "cell_type": "markdown", - "id": "08e33b46", + "id": "56c48732", "metadata": {}, "source": [ "

\n", @@ -183,7 +183,7 @@ }, { "cell_type": "markdown", - "id": "fee2f87c", + "id": "e8d4a45f", "metadata": {}, "source": [ "

\n", @@ -194,7 +194,7 @@ }, { "cell_type": "markdown", - "id": "3581f01f", + "id": "313961e4", "metadata": {}, "source": [ "## Part 1.2: Global Corruption of data\n", @@ -204,7 +204,7 @@ }, { "cell_type": "markdown", - "id": "6447348c", + "id": "3ad9b40a", "metadata": {}, "source": [ "You may have noticed that the images are stored as arrays of integers. First we cast them to float to be able to add textures easily without integer wrapping issues." @@ -213,7 +213,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b3731533", + "id": "5fa9ce0f", "metadata": {}, "outputs": [], "source": [ @@ -224,7 +224,7 @@ }, { "cell_type": "markdown", - "id": "7adcabd3", + "id": "9d04663d", "metadata": {}, "source": [ "Then we create the grid texture and visualize it." @@ -233,7 +233,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6b604fa3", + "id": "f6567330", "metadata": {}, "outputs": [], "source": [ @@ -249,7 +249,7 @@ }, { "cell_type": "markdown", - "id": "c1368fb3", + "id": "7f0de8d6", "metadata": {}, "source": [ "Next we add the texture to all 4s in the train and test set." @@ -258,7 +258,7 @@ { "cell_type": "code", "execution_count": null, - "id": "38a80836", + "id": "09a9d0a9", "metadata": {}, "outputs": [], "source": [ @@ -269,7 +269,7 @@ }, { "cell_type": "markdown", - "id": "cf303dd0", + "id": "258d63ca", "metadata": {}, "source": [ "After adding the texture, we have to make sure the values are between 0 and 255 and then cast back to uint8.\n", @@ -279,7 +279,7 @@ { "cell_type": "code", "execution_count": null, - "id": "503dcb25", + "id": "2efaf1a3", "metadata": {}, "outputs": [], "source": [ @@ -295,7 +295,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7781c186", + "id": "cd721195", "metadata": {}, "outputs": [], "source": [ @@ -317,7 +317,7 @@ }, { "cell_type": "markdown", - "id": "4ec55e8d", + "id": "d67365c8", "metadata": {}, "source": [ "

\n", @@ -328,7 +328,7 @@ }, { "cell_type": "markdown", - "id": "33f601d3", + "id": "d3ef113a", "metadata": {}, "source": [ "\n", @@ -340,7 +340,7 @@ }, { "cell_type": "markdown", - "id": "c4f22201", + "id": "c1bfdb47", "metadata": {}, "source": [ "\n", @@ -353,7 +353,7 @@ }, { "cell_type": "markdown", - "id": "f7407f20", + "id": "b6d30dbe", "metadata": {}, "source": [ "\n", @@ -371,7 +371,7 @@ }, { "cell_type": "markdown", - "id": "f126c5e4", + "id": "4a287ac7", "metadata": {}, "source": [ "### Part 2: Create and Train an Image Classification Neural Network on Clean and Tainted Data\n", @@ -382,7 +382,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eda4fb9a", + "id": "ac95a141", "metadata": {}, "outputs": [], "source": [ @@ -396,7 +396,7 @@ }, { "cell_type": "markdown", - "id": "fcba2a9c", + "id": "877712c4", "metadata": {}, "source": [ "Now we will train the neural network. A training function is provided below - this should be familiar, but make sure you look it over and understand what is happening in the training loop." @@ -405,7 +405,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1d7471e6", + "id": "c1422627", "metadata": {}, "outputs": [], "source": [ @@ -430,7 +430,7 @@ }, { "cell_type": "markdown", - "id": "b20e8ef1", + "id": "ed5e795b", "metadata": {}, "source": [ "We have to choose hyperparameters for our model. We have selected to train for two epochs, with a batch size of 64 for training and 1000 for testing. We are using the cross entropy loss, a standard multi-class classification loss." @@ -439,7 +439,7 @@ { "cell_type": "code", "execution_count": null, - "id": "67dc8176", + "id": "1ba33ba2", "metadata": {}, "outputs": [], "source": [ @@ -458,7 +458,7 @@ }, { "cell_type": "markdown", - "id": "c167e7f1", + "id": "60ced296", "metadata": {}, "source": [ "Next we initialize a clean model, and a tainted model. We want to have reproducible results, so we set the initial weights with a specific random seed. The seed number does not matter, just that it is the same!" @@ -467,7 +467,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c5ed5585", + "id": "cfe75176", "metadata": {}, "outputs": [], "source": [ @@ -495,7 +495,7 @@ }, { "cell_type": "markdown", - "id": "ef87074c", + "id": "ade17375", "metadata": {}, "source": [ "Next we initialize the clean and tainted dataloaders, again with a specific random seed for reproducibility." @@ -504,7 +504,7 @@ { "cell_type": "code", "execution_count": null, - "id": "dbcf65c9", + "id": "7c6306f1", "metadata": {}, "outputs": [], "source": [ @@ -518,7 +518,7 @@ }, { "cell_type": "markdown", - "id": "9cb8b4b4", + "id": "ca3ddf3a", "metadata": {}, "source": [ "Now it is time to train the neural networks! We are storing the training loss history for each model so we can visualize it later." @@ -527,7 +527,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1ff6bb66", + "id": "a015ae98", "metadata": {}, "outputs": [], "source": [ @@ -560,7 +560,7 @@ }, { "cell_type": "markdown", - "id": "f389ca38", + "id": "0525920d", "metadata": {}, "source": [ "Now we visualize the loss history for the clean and tainted models." @@ -569,7 +569,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9473ae0f", + "id": "a2f818ac", "metadata": {}, "outputs": [], "source": [ @@ -584,7 +584,7 @@ }, { "cell_type": "markdown", - "id": "5b6c2993", + "id": "08ad1d0f", "metadata": {}, "source": [ "

\n", @@ -595,7 +595,7 @@ }, { "cell_type": "markdown", - "id": "db77e034", + "id": "1fb4c6ad", "metadata": {}, "source": [ "

\n", @@ -606,7 +606,7 @@ }, { "cell_type": "markdown", - "id": "4aed0994", + "id": "7621a5ec", "metadata": {}, "source": [ "

\n", @@ -617,7 +617,7 @@ }, { "cell_type": "markdown", - "id": "e2ad4888", + "id": "d1b2cd0a", "metadata": {}, "source": [ "

\n", @@ -629,7 +629,7 @@ }, { "cell_type": "markdown", - "id": "fd85af08", + "id": "86a2249f", "metadata": {}, "source": [ "

\n", @@ -644,7 +644,7 @@ }, { "cell_type": "markdown", - "id": "35faa65c", + "id": "5c34720a", "metadata": {}, "source": [ "### Part 3: Examining the Results of the Clean and Tainted Networks\n", @@ -657,7 +657,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b9571f86", + "id": "b34f442e", "metadata": {}, "outputs": [], "source": [ @@ -679,16 +679,16 @@ }, { "cell_type": "markdown", - "id": "1ba7a46b", + "id": "56a6d351", "metadata": {}, "source": [ - "Now we call the predict method with the clean and tainted models on the clean and tainted datasets." + "Now we call the predict function with the clean and tainted models on the clean and tainted datasets." ] }, { "cell_type": "code", "execution_count": null, - "id": "a64f5d22", + "id": "1969c54d", "metadata": {}, "outputs": [], "source": [ @@ -700,16 +700,16 @@ }, { "cell_type": "markdown", - "id": "2937a3f5", + "id": "eef029ca", "metadata": {}, "source": [ - "We can investigate the results using the confusion matrix, which you should recall from the Introduction to Machine Learning exercise. The function in the cell below will create a nicely annotated confusion matrix." + "We can investigate the results using the confusion matrix, you can read more about them [here](https://en.wikipedia.org/wiki/Confusion_matrix). The function in the cell below will create a nicely annotated confusion matrix." ] }, { "cell_type": "code", "execution_count": null, - "id": "2d99588f", + "id": "6187a24b", "metadata": { "lines_to_next_cell": 1 }, @@ -764,7 +764,7 @@ }, { "cell_type": "markdown", - "id": "ba93ea0c", + "id": "e622ce90", "metadata": {}, "source": [ "Now we will generate confusion matrices for each model/data combination. Take your time and try and interpret these, and then try and answer the questions below." @@ -773,7 +773,7 @@ { "cell_type": "code", "execution_count": null, - "id": "03fa45d8", + "id": "475bffc6", "metadata": {}, "outputs": [], "source": [ @@ -785,7 +785,7 @@ }, { "cell_type": "markdown", - "id": "0d65dd6b", + "id": "bba727d2", "metadata": {}, "source": [ "

\n", @@ -796,7 +796,7 @@ }, { "cell_type": "markdown", - "id": "54c38a61", + "id": "06984c4e", "metadata": {}, "source": [ "

\n", @@ -807,7 +807,7 @@ }, { "cell_type": "markdown", - "id": "afcf048a", + "id": "2b482a41", "metadata": {}, "source": [ "

\n", @@ -818,7 +818,7 @@ }, { "cell_type": "markdown", - "id": "c5751b3e", + "id": "af274b10", "metadata": {}, "source": [ "

\n", @@ -829,7 +829,7 @@ }, { "cell_type": "markdown", - "id": "d2812f67", + "id": "a665e4f4", "metadata": {}, "source": [ "

\n", @@ -841,7 +841,7 @@ }, { "cell_type": "markdown", - "id": "8d411a40", + "id": "e0e4cdeb", "metadata": {}, "source": [ "

\n", @@ -856,7 +856,7 @@ }, { "cell_type": "markdown", - "id": "8249ac3d", + "id": "8de92202", "metadata": {}, "source": [ "### Part 4: Interpretation with Integrated Gradients\n", @@ -865,7 +865,7 @@ }, { "cell_type": "markdown", - "id": "7c235272", + "id": "e0639e5e", "metadata": {}, "source": [ "\n", @@ -875,7 +875,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b2d82d85", + "id": "b50e9c08", "metadata": {}, "outputs": [], "source": [ @@ -908,7 +908,7 @@ }, { "cell_type": "markdown", - "id": "a20292b4", + "id": "6678dbc7", "metadata": {}, "source": [ "Next we provide a function to visualize the output of integrated gradients, using the function above to actually run the algorithm." @@ -917,7 +917,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f39b4d66", + "id": "060f82c7", "metadata": {}, "outputs": [], "source": [ @@ -956,7 +956,7 @@ }, { "cell_type": "markdown", - "id": "89ca294b", + "id": "a8f2f5dc", "metadata": {}, "source": [ "To start examining the results, we will call the `visualize_integrated_gradients` with the tainted and clean models on the tainted and clean sevens.\n", @@ -967,7 +967,7 @@ { "cell_type": "code", "execution_count": null, - "id": "68a1916d", + "id": "3f5ef85c", "metadata": {}, "outputs": [], "source": [ @@ -977,7 +977,7 @@ }, { "cell_type": "markdown", - "id": "1a3c24c8", + "id": "679f1abf", "metadata": {}, "source": [ "

\n", @@ -988,7 +988,7 @@ }, { "cell_type": "markdown", - "id": "039bdb2d", + "id": "ee6a115e", "metadata": {}, "source": [ "Now let's look at the attention of the tainted model!" @@ -997,7 +997,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f42237ef", + "id": "feaecde7", "metadata": {}, "outputs": [], "source": [ @@ -1007,7 +1007,7 @@ }, { "cell_type": "markdown", - "id": "7666839c", + "id": "9801b4af", "metadata": {}, "source": [ "

\n", @@ -1018,7 +1018,7 @@ }, { "cell_type": "markdown", - "id": "20006a90", + "id": "a735c2c4", "metadata": {}, "source": [ "Now let's look at the regions of the image that Integrated Gradients highlights as important for classifying fours in the clean and tainted models." @@ -1027,7 +1027,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f2b422de", + "id": "d9bc08a9", "metadata": {}, "outputs": [], "source": [ @@ -1039,7 +1039,7 @@ }, { "cell_type": "markdown", - "id": "f3470b70", + "id": "b0ec1340", "metadata": {}, "source": [ "

\n", @@ -1050,7 +1050,7 @@ }, { "cell_type": "markdown", - "id": "2b2ccff7", + "id": "a14c35bf", "metadata": {}, "source": [ "

\n", @@ -1061,7 +1061,7 @@ }, { "cell_type": "markdown", - "id": "77638560", + "id": "81ea4131", "metadata": {}, "source": [ "

\n", @@ -1074,7 +1074,7 @@ }, { "cell_type": "markdown", - "id": "0e7c467c", + "id": "4fd3f863", "metadata": {}, "source": [ "

\n", @@ -1088,7 +1088,7 @@ }, { "cell_type": "markdown", - "id": "d5b37c02", + "id": "72c35c46", "metadata": {}, "source": [ "## Part 5: Importance of using the right training data\n", @@ -1100,7 +1100,7 @@ }, { "cell_type": "markdown", - "id": "4ab7521d", + "id": "98073861", "metadata": {}, "source": [ "First, we will write a function to add noise to the MNIST dataset, so that we can train a model to denoise it." @@ -1109,7 +1109,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15340fcc", + "id": "8d114487", "metadata": {}, "outputs": [], "source": [ @@ -1122,7 +1122,7 @@ }, { "cell_type": "markdown", - "id": "bcb17b47", + "id": "0e18941a", "metadata": {}, "source": [ "Next we will visualize a couple MNIST examples with and without noise." @@ -1131,7 +1131,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3f4142ec", + "id": "e0a8600b", "metadata": {}, "outputs": [], "source": [ @@ -1160,7 +1160,7 @@ }, { "cell_type": "markdown", - "id": "32177f2e", + "id": "6b9f78a6", "metadata": {}, "source": [ "### UNet model\n", @@ -1170,7 +1170,7 @@ }, { "cell_type": "markdown", - "id": "0bde3d98", + "id": "bf5413d0", "metadata": {}, "source": [ "The training loop code is also provided here. It is similar to the code used to train the image classification model previously, but look it over to make sure there are no surprises." @@ -1179,7 +1179,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e642d956", + "id": "2b3698cd", "metadata": {}, "outputs": [], "source": [ @@ -1227,7 +1227,7 @@ }, { "cell_type": "markdown", - "id": "f82de800", + "id": "bf0121bd", "metadata": {}, "source": [ "Here we choose hyperparameters and initialize the model and data loaders." @@ -1236,7 +1236,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3cf1768f", + "id": "f98bfc29", "metadata": {}, "outputs": [], "source": [ @@ -1274,7 +1274,7 @@ }, { "cell_type": "markdown", - "id": "c6491e06", + "id": "373b9235", "metadata": {}, "source": [ "Finally, we run the training loop!" @@ -1283,7 +1283,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a8ff968c", + "id": "1f174267", "metadata": {}, "outputs": [], "source": [ @@ -1294,7 +1294,7 @@ }, { "cell_type": "markdown", - "id": "2c0e657c", + "id": "696f7072", "metadata": {}, "source": [ "As before, we will visualize the training loss. If all went correctly, it should decrease from around 1.0 to less than 0.2." @@ -1303,7 +1303,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a5f92989", + "id": "d831df5e", "metadata": { "lines_to_next_cell": 1 }, @@ -1319,7 +1319,7 @@ }, { "cell_type": "markdown", - "id": "1ff69a50", + "id": "cef6c1d9", "metadata": {}, "source": [ "### Check denoising performance\n", @@ -1330,7 +1330,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1d3ff452", + "id": "93cb5ffa", "metadata": { "lines_to_next_cell": 1 }, @@ -1347,7 +1347,7 @@ { "cell_type": "code", "execution_count": null, - "id": "680d1a79", + "id": "8465bdfc", "metadata": { "lines_to_next_cell": 1 }, @@ -1373,7 +1373,7 @@ }, { "cell_type": "markdown", - "id": "dd293e3c", + "id": "064f938a", "metadata": {}, "source": [ "We pick 8 images to show:" @@ -1382,7 +1382,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d950e273", + "id": "170dbf3e", "metadata": {}, "outputs": [], "source": [ @@ -1392,7 +1392,7 @@ }, { "cell_type": "markdown", - "id": "5093a370", + "id": "ea1aff66", "metadata": {}, "source": [ "

\n", @@ -1403,7 +1403,7 @@ }, { "cell_type": "markdown", - "id": "3e5bdd01", + "id": "5229fbd8", "metadata": {}, "source": [ "### Apply trained model on 'wrong' data\n", @@ -1413,7 +1413,7 @@ }, { "cell_type": "markdown", - "id": "08970f43", + "id": "6970de96", "metadata": {}, "source": [ "### Load the Fashion MNIST dataset\n", @@ -1424,7 +1424,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e96ed5e7", + "id": "8cd71231", "metadata": {}, "outputs": [], "source": [ @@ -1445,7 +1445,7 @@ }, { "cell_type": "markdown", - "id": "f00758c2", + "id": "9f3463fc", "metadata": {}, "source": [ "Next we apply the denoising model we trained on the MNIST data to FashionMNIST, and visualize the results." @@ -1454,7 +1454,7 @@ { "cell_type": "code", "execution_count": null, - "id": "89b14b4b", + "id": "d8eb6ca9", "metadata": {}, "outputs": [], "source": [ @@ -1464,7 +1464,7 @@ }, { "cell_type": "markdown", - "id": "5e1870b6", + "id": "cd5b8116", "metadata": {}, "source": [ "

\n", @@ -1475,7 +1475,7 @@ }, { "cell_type": "markdown", - "id": "19f2c40c", + "id": "e8fd1056", "metadata": {}, "source": [ "

\n", @@ -1486,7 +1486,7 @@ }, { "cell_type": "markdown", - "id": "fb0eeb74", + "id": "f76513da", "metadata": {}, "source": [ "### Train the denoiser on both MNIST and FashionMNIST\n", @@ -1497,7 +1497,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eb150490", + "id": "24425a33", "metadata": {}, "outputs": [], "source": [ @@ -1534,7 +1534,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ca64cf2e", + "id": "7b561f01", "metadata": {}, "outputs": [], "source": [ @@ -1545,7 +1545,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8574e737", + "id": "4bbc903b", "metadata": {}, "outputs": [], "source": [ @@ -1555,7 +1555,7 @@ }, { "cell_type": "markdown", - "id": "84a7865c", + "id": "05c96c6f", "metadata": {}, "source": [ "

\n", @@ -1566,7 +1566,7 @@ }, { "cell_type": "markdown", - "id": "9bb4a705", + "id": "ea773de2", "metadata": {}, "source": [ "### Train the denoiser on both MNIST and FashionMNIST, shuffling the training data\n", @@ -1577,7 +1577,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d229e0fa", + "id": "59f373b2", "metadata": {}, "outputs": [], "source": [ @@ -1614,7 +1614,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2085c32f", + "id": "76162517", "metadata": {}, "outputs": [], "source": [ @@ -1625,7 +1625,7 @@ { "cell_type": "code", "execution_count": null, - "id": "631c1b64", + "id": "3f38e5ae", "metadata": {}, "outputs": [], "source": [ @@ -1635,7 +1635,7 @@ }, { "cell_type": "markdown", - "id": "83bffaba", + "id": "42840fdf", "metadata": {}, "source": [ "

\n", @@ -1646,7 +1646,7 @@ }, { "cell_type": "markdown", - "id": "1b7c9fcf", + "id": "506aa6ce", "metadata": {}, "source": [ "\n", @@ -1660,7 +1660,7 @@ }, { "cell_type": "markdown", - "id": "c258e7ae", + "id": "7d29b67d", "metadata": {}, "source": [ "\n", @@ -1674,7 +1674,7 @@ }, { "cell_type": "markdown", - "id": "11700dbd", + "id": "e837cbed", "metadata": {}, "source": [] } diff --git a/solution.ipynb b/solution.ipynb index 0557485..d226fe0 100644 --- a/solution.ipynb +++ b/solution.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "055f5871", + "id": "b914acba", "metadata": {}, "source": [ "# Exercise 7: Failure Modes And Limits of Deep Learning" @@ -10,7 +10,7 @@ }, { "cell_type": "markdown", - "id": "327d7b71", + "id": "6c1c3a9b", "metadata": {}, "source": [ "In the following exercise, we explore the failure modes and limits of neural networks.\n", @@ -23,7 +23,7 @@ }, { "cell_type": "markdown", - "id": "41654ae2", + "id": "2e85adb6", "metadata": {}, "source": [ "\n", @@ -44,7 +44,7 @@ }, { "cell_type": "markdown", - "id": "0a64a471", + "id": "a43fe7eb", "metadata": {}, "source": [ "### Acknowledgements\n", @@ -53,7 +53,7 @@ }, { "cell_type": "markdown", - "id": "b5bcabb9", + "id": "4683adbf", "metadata": {}, "source": [ "### Data Loading\n", @@ -67,7 +67,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9d41afcb", + "id": "fdb18bd2", "metadata": {}, "outputs": [], "source": [ @@ -90,7 +90,7 @@ }, { "cell_type": "markdown", - "id": "1d04380a", + "id": "9a5490e9", "metadata": {}, "source": [ "### Part 1: Preparation of a Tainted Dataset\n", @@ -101,7 +101,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9b0b1a97", + "id": "23e03cf0", "metadata": {}, "outputs": [], "source": [ @@ -115,7 +115,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4d83f1a2", + "id": "b0f72652", "metadata": {}, "outputs": [], "source": [ @@ -126,7 +126,7 @@ }, { "cell_type": "markdown", - "id": "12b9d7af", + "id": "e055a001", "metadata": {}, "source": [ "## Part 1.1: Local Corruption of Data\n", @@ -137,7 +137,7 @@ { "cell_type": "code", "execution_count": null, - "id": "022103f5", + "id": "a12a3a3f", "metadata": {}, "outputs": [], "source": [ @@ -149,7 +149,7 @@ { "cell_type": "code", "execution_count": null, - "id": "64ea44e2", + "id": "3de5e726", "metadata": {}, "outputs": [], "source": [ @@ -172,7 +172,7 @@ }, { "cell_type": "markdown", - "id": "08e33b46", + "id": "56c48732", "metadata": {}, "source": [ "

\n", @@ -183,7 +183,7 @@ }, { "cell_type": "markdown", - "id": "6195f9ef", + "id": "40133d05", "metadata": { "tags": [ "solution" @@ -199,7 +199,7 @@ }, { "cell_type": "markdown", - "id": "797de443", + "id": "854c3920", "metadata": { "tags": [ "solution" @@ -215,7 +215,7 @@ }, { "cell_type": "markdown", - "id": "fee2f87c", + "id": "e8d4a45f", "metadata": {}, "source": [ "

\n", @@ -226,7 +226,7 @@ }, { "cell_type": "markdown", - "id": "4a89fd8a", + "id": "4be963f1", "metadata": { "tags": [ "solution" @@ -240,7 +240,7 @@ }, { "cell_type": "markdown", - "id": "a58f5dfb", + "id": "e2597969", "metadata": { "tags": [ "solution" @@ -261,7 +261,7 @@ }, { "cell_type": "markdown", - "id": "3581f01f", + "id": "313961e4", "metadata": {}, "source": [ "## Part 1.2: Global Corruption of data\n", @@ -271,7 +271,7 @@ }, { "cell_type": "markdown", - "id": "6447348c", + "id": "3ad9b40a", "metadata": {}, "source": [ "You may have noticed that the images are stored as arrays of integers. First we cast them to float to be able to add textures easily without integer wrapping issues." @@ -280,7 +280,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b3731533", + "id": "5fa9ce0f", "metadata": {}, "outputs": [], "source": [ @@ -291,7 +291,7 @@ }, { "cell_type": "markdown", - "id": "7adcabd3", + "id": "9d04663d", "metadata": {}, "source": [ "Then we create the grid texture and visualize it." @@ -300,7 +300,7 @@ { "cell_type": "code", "execution_count": null, - "id": "6b604fa3", + "id": "f6567330", "metadata": {}, "outputs": [], "source": [ @@ -316,7 +316,7 @@ }, { "cell_type": "markdown", - "id": "c1368fb3", + "id": "7f0de8d6", "metadata": {}, "source": [ "Next we add the texture to all 4s in the train and test set." @@ -325,7 +325,7 @@ { "cell_type": "code", "execution_count": null, - "id": "38a80836", + "id": "09a9d0a9", "metadata": {}, "outputs": [], "source": [ @@ -336,7 +336,7 @@ }, { "cell_type": "markdown", - "id": "cf303dd0", + "id": "258d63ca", "metadata": {}, "source": [ "After adding the texture, we have to make sure the values are between 0 and 255 and then cast back to uint8.\n", @@ -346,7 +346,7 @@ { "cell_type": "code", "execution_count": null, - "id": "503dcb25", + "id": "2efaf1a3", "metadata": {}, "outputs": [], "source": [ @@ -362,7 +362,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7781c186", + "id": "cd721195", "metadata": {}, "outputs": [], "source": [ @@ -384,7 +384,7 @@ }, { "cell_type": "markdown", - "id": "4ec55e8d", + "id": "d67365c8", "metadata": {}, "source": [ "

\n", @@ -395,7 +395,7 @@ }, { "cell_type": "markdown", - "id": "3fae04f1", + "id": "f6ce4f56", "metadata": { "tags": [ "solution" @@ -413,7 +413,7 @@ }, { "cell_type": "markdown", - "id": "f003eab9", + "id": "e0d70ea2", "metadata": { "tags": [ "solution" @@ -442,7 +442,7 @@ }, { "cell_type": "markdown", - "id": "33f601d3", + "id": "d3ef113a", "metadata": {}, "source": [ "\n", @@ -454,7 +454,7 @@ }, { "cell_type": "markdown", - "id": "12c7f43e", + "id": "2b205608", "metadata": { "tags": [ "solution" @@ -468,7 +468,7 @@ }, { "cell_type": "markdown", - "id": "eaa89530", + "id": "f6e76085", "metadata": { "tags": [ "solution" @@ -482,7 +482,7 @@ }, { "cell_type": "markdown", - "id": "c4f22201", + "id": "c1bfdb47", "metadata": {}, "source": [ "\n", @@ -495,7 +495,7 @@ }, { "cell_type": "markdown", - "id": "f7407f20", + "id": "b6d30dbe", "metadata": {}, "source": [ "\n", @@ -513,7 +513,7 @@ }, { "cell_type": "markdown", - "id": "f126c5e4", + "id": "4a287ac7", "metadata": {}, "source": [ "### Part 2: Create and Train an Image Classification Neural Network on Clean and Tainted Data\n", @@ -524,7 +524,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eda4fb9a", + "id": "ac95a141", "metadata": {}, "outputs": [], "source": [ @@ -538,7 +538,7 @@ }, { "cell_type": "markdown", - "id": "fcba2a9c", + "id": "877712c4", "metadata": {}, "source": [ "Now we will train the neural network. A training function is provided below - this should be familiar, but make sure you look it over and understand what is happening in the training loop." @@ -547,7 +547,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1d7471e6", + "id": "c1422627", "metadata": {}, "outputs": [], "source": [ @@ -572,7 +572,7 @@ }, { "cell_type": "markdown", - "id": "b20e8ef1", + "id": "ed5e795b", "metadata": {}, "source": [ "We have to choose hyperparameters for our model. We have selected to train for two epochs, with a batch size of 64 for training and 1000 for testing. We are using the cross entropy loss, a standard multi-class classification loss." @@ -581,7 +581,7 @@ { "cell_type": "code", "execution_count": null, - "id": "67dc8176", + "id": "1ba33ba2", "metadata": {}, "outputs": [], "source": [ @@ -600,7 +600,7 @@ }, { "cell_type": "markdown", - "id": "c167e7f1", + "id": "60ced296", "metadata": {}, "source": [ "Next we initialize a clean model, and a tainted model. We want to have reproducible results, so we set the initial weights with a specific random seed. The seed number does not matter, just that it is the same!" @@ -609,7 +609,7 @@ { "cell_type": "code", "execution_count": null, - "id": "c5ed5585", + "id": "cfe75176", "metadata": {}, "outputs": [], "source": [ @@ -637,7 +637,7 @@ }, { "cell_type": "markdown", - "id": "ef87074c", + "id": "ade17375", "metadata": {}, "source": [ "Next we initialize the clean and tainted dataloaders, again with a specific random seed for reproducibility." @@ -646,7 +646,7 @@ { "cell_type": "code", "execution_count": null, - "id": "dbcf65c9", + "id": "7c6306f1", "metadata": {}, "outputs": [], "source": [ @@ -660,7 +660,7 @@ }, { "cell_type": "markdown", - "id": "9cb8b4b4", + "id": "ca3ddf3a", "metadata": {}, "source": [ "Now it is time to train the neural networks! We are storing the training loss history for each model so we can visualize it later." @@ -669,7 +669,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1ff6bb66", + "id": "a015ae98", "metadata": {}, "outputs": [], "source": [ @@ -702,7 +702,7 @@ }, { "cell_type": "markdown", - "id": "f389ca38", + "id": "0525920d", "metadata": {}, "source": [ "Now we visualize the loss history for the clean and tainted models." @@ -711,7 +711,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9473ae0f", + "id": "a2f818ac", "metadata": {}, "outputs": [], "source": [ @@ -726,7 +726,7 @@ }, { "cell_type": "markdown", - "id": "5b6c2993", + "id": "08ad1d0f", "metadata": {}, "source": [ "

\n", @@ -737,7 +737,7 @@ }, { "cell_type": "markdown", - "id": "db3a2aef", + "id": "5036566d", "metadata": { "tags": [ "solution" @@ -751,7 +751,7 @@ }, { "cell_type": "markdown", - "id": "f73fba19", + "id": "f0f5f4b4", "metadata": { "tags": [ "solution" @@ -765,7 +765,7 @@ }, { "cell_type": "markdown", - "id": "db77e034", + "id": "1fb4c6ad", "metadata": {}, "source": [ "

\n", @@ -776,7 +776,7 @@ }, { "cell_type": "markdown", - "id": "384c3592", + "id": "577eb486", "metadata": { "tags": [ "solution" @@ -790,7 +790,7 @@ }, { "cell_type": "markdown", - "id": "87fbc8a6", + "id": "fa0214d7", "metadata": { "tags": [ "solution" @@ -804,7 +804,7 @@ }, { "cell_type": "markdown", - "id": "4aed0994", + "id": "7621a5ec", "metadata": {}, "source": [ "

\n", @@ -815,7 +815,7 @@ }, { "cell_type": "markdown", - "id": "4a8d9f85", + "id": "89829708", "metadata": { "tags": [ "solution" @@ -829,7 +829,7 @@ }, { "cell_type": "markdown", - "id": "cefcccfc", + "id": "e35306fa", "metadata": { "tags": [ "solution" @@ -843,7 +843,7 @@ }, { "cell_type": "markdown", - "id": "e2ad4888", + "id": "d1b2cd0a", "metadata": {}, "source": [ "

\n", @@ -855,7 +855,7 @@ }, { "cell_type": "markdown", - "id": "fd85af08", + "id": "86a2249f", "metadata": {}, "source": [ "

\n", @@ -870,7 +870,7 @@ }, { "cell_type": "markdown", - "id": "35faa65c", + "id": "5c34720a", "metadata": {}, "source": [ "### Part 3: Examining the Results of the Clean and Tainted Networks\n", @@ -883,7 +883,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b9571f86", + "id": "b34f442e", "metadata": {}, "outputs": [], "source": [ @@ -905,16 +905,16 @@ }, { "cell_type": "markdown", - "id": "1ba7a46b", + "id": "56a6d351", "metadata": {}, "source": [ - "Now we call the predict method with the clean and tainted models on the clean and tainted datasets." + "Now we call the predict function with the clean and tainted models on the clean and tainted datasets." ] }, { "cell_type": "code", "execution_count": null, - "id": "a64f5d22", + "id": "1969c54d", "metadata": {}, "outputs": [], "source": [ @@ -926,16 +926,16 @@ }, { "cell_type": "markdown", - "id": "2937a3f5", + "id": "eef029ca", "metadata": {}, "source": [ - "We can investigate the results using the confusion matrix, which you should recall from the Introduction to Machine Learning exercise. The function in the cell below will create a nicely annotated confusion matrix." + "We can investigate the results using the confusion matrix, you can read more about them [here](https://en.wikipedia.org/wiki/Confusion_matrix). The function in the cell below will create a nicely annotated confusion matrix." ] }, { "cell_type": "code", "execution_count": null, - "id": "2d99588f", + "id": "6187a24b", "metadata": { "lines_to_next_cell": 1 }, @@ -990,7 +990,7 @@ }, { "cell_type": "markdown", - "id": "ba93ea0c", + "id": "e622ce90", "metadata": {}, "source": [ "Now we will generate confusion matrices for each model/data combination. Take your time and try and interpret these, and then try and answer the questions below." @@ -999,7 +999,7 @@ { "cell_type": "code", "execution_count": null, - "id": "03fa45d8", + "id": "475bffc6", "metadata": {}, "outputs": [], "source": [ @@ -1011,7 +1011,7 @@ }, { "cell_type": "markdown", - "id": "0d65dd6b", + "id": "bba727d2", "metadata": {}, "source": [ "

\n", @@ -1022,7 +1022,7 @@ }, { "cell_type": "markdown", - "id": "a242141f", + "id": "c3fc1305", "metadata": { "tags": [ "solution" @@ -1036,7 +1036,7 @@ }, { "cell_type": "markdown", - "id": "7056d957", + "id": "10931ca1", "metadata": { "tags": [ "solution" @@ -1051,7 +1051,7 @@ }, { "cell_type": "markdown", - "id": "54c38a61", + "id": "06984c4e", "metadata": {}, "source": [ "

\n", @@ -1062,7 +1062,7 @@ }, { "cell_type": "markdown", - "id": "e9d8355a", + "id": "fb3c676d", "metadata": { "tags": [ "solution" @@ -1076,7 +1076,7 @@ }, { "cell_type": "markdown", - "id": "5f231071", + "id": "2d9657d9", "metadata": { "tags": [ "solution" @@ -1090,7 +1090,7 @@ }, { "cell_type": "markdown", - "id": "afcf048a", + "id": "2b482a41", "metadata": {}, "source": [ "

\n", @@ -1101,7 +1101,7 @@ }, { "cell_type": "markdown", - "id": "27a27d7d", + "id": "1a673a28", "metadata": { "tags": [ "solution" @@ -1115,7 +1115,7 @@ }, { "cell_type": "markdown", - "id": "562d72a5", + "id": "f36004fb", "metadata": { "tags": [ "solution" @@ -1132,7 +1132,7 @@ }, { "cell_type": "markdown", - "id": "c5751b3e", + "id": "af274b10", "metadata": {}, "source": [ "

\n", @@ -1143,7 +1143,7 @@ }, { "cell_type": "markdown", - "id": "c670d437", + "id": "57828442", "metadata": { "tags": [ "solution" @@ -1157,7 +1157,7 @@ }, { "cell_type": "markdown", - "id": "7018f722", + "id": "3ad2788b", "metadata": { "tags": [ "solution" @@ -1177,7 +1177,7 @@ }, { "cell_type": "markdown", - "id": "d2812f67", + "id": "a665e4f4", "metadata": {}, "source": [ "

\n", @@ -1189,7 +1189,7 @@ }, { "cell_type": "markdown", - "id": "8d411a40", + "id": "e0e4cdeb", "metadata": {}, "source": [ "

\n", @@ -1204,7 +1204,7 @@ }, { "cell_type": "markdown", - "id": "8249ac3d", + "id": "8de92202", "metadata": {}, "source": [ "### Part 4: Interpretation with Integrated Gradients\n", @@ -1213,7 +1213,7 @@ }, { "cell_type": "markdown", - "id": "7c235272", + "id": "e0639e5e", "metadata": {}, "source": [ "\n", @@ -1223,7 +1223,7 @@ { "cell_type": "code", "execution_count": null, - "id": "b2d82d85", + "id": "b50e9c08", "metadata": {}, "outputs": [], "source": [ @@ -1256,7 +1256,7 @@ }, { "cell_type": "markdown", - "id": "a20292b4", + "id": "6678dbc7", "metadata": {}, "source": [ "Next we provide a function to visualize the output of integrated gradients, using the function above to actually run the algorithm." @@ -1265,7 +1265,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f39b4d66", + "id": "060f82c7", "metadata": {}, "outputs": [], "source": [ @@ -1304,7 +1304,7 @@ }, { "cell_type": "markdown", - "id": "89ca294b", + "id": "a8f2f5dc", "metadata": {}, "source": [ "To start examining the results, we will call the `visualize_integrated_gradients` with the tainted and clean models on the tainted and clean sevens.\n", @@ -1315,7 +1315,7 @@ { "cell_type": "code", "execution_count": null, - "id": "68a1916d", + "id": "3f5ef85c", "metadata": {}, "outputs": [], "source": [ @@ -1325,7 +1325,7 @@ }, { "cell_type": "markdown", - "id": "1a3c24c8", + "id": "679f1abf", "metadata": {}, "source": [ "

\n", @@ -1336,7 +1336,7 @@ }, { "cell_type": "markdown", - "id": "91c49b74", + "id": "333431ef", "metadata": { "tags": [ "solution" @@ -1350,7 +1350,7 @@ }, { "cell_type": "markdown", - "id": "9e0d6db2", + "id": "1f646990", "metadata": { "tags": [ "solution" @@ -1365,7 +1365,7 @@ }, { "cell_type": "markdown", - "id": "039bdb2d", + "id": "ee6a115e", "metadata": {}, "source": [ "Now let's look at the attention of the tainted model!" @@ -1374,7 +1374,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f42237ef", + "id": "feaecde7", "metadata": {}, "outputs": [], "source": [ @@ -1384,7 +1384,7 @@ }, { "cell_type": "markdown", - "id": "7666839c", + "id": "9801b4af", "metadata": {}, "source": [ "

\n", @@ -1395,7 +1395,7 @@ }, { "cell_type": "markdown", - "id": "7e580a75", + "id": "20435c91", "metadata": { "tags": [ "solution" @@ -1409,7 +1409,7 @@ }, { "cell_type": "markdown", - "id": "8b78225a", + "id": "30b37d5e", "metadata": { "tags": [ "solution" @@ -1427,7 +1427,7 @@ }, { "cell_type": "markdown", - "id": "20006a90", + "id": "a735c2c4", "metadata": {}, "source": [ "Now let's look at the regions of the image that Integrated Gradients highlights as important for classifying fours in the clean and tainted models." @@ -1436,7 +1436,7 @@ { "cell_type": "code", "execution_count": null, - "id": "f2b422de", + "id": "d9bc08a9", "metadata": {}, "outputs": [], "source": [ @@ -1448,7 +1448,7 @@ }, { "cell_type": "markdown", - "id": "f3470b70", + "id": "b0ec1340", "metadata": {}, "source": [ "

\n", @@ -1459,7 +1459,7 @@ }, { "cell_type": "markdown", - "id": "3af071e0", + "id": "fdb6c15e", "metadata": { "tags": [ "solution" @@ -1473,7 +1473,7 @@ }, { "cell_type": "markdown", - "id": "f5614261", + "id": "5efe90f1", "metadata": { "tags": [ "solution" @@ -1490,7 +1490,7 @@ }, { "cell_type": "markdown", - "id": "2b2ccff7", + "id": "a14c35bf", "metadata": {}, "source": [ "

\n", @@ -1501,7 +1501,7 @@ }, { "cell_type": "markdown", - "id": "55a09b6c", + "id": "492270e6", "metadata": { "tags": [ "solution" @@ -1515,7 +1515,7 @@ }, { "cell_type": "markdown", - "id": "113d50b3", + "id": "e53d66a6", "metadata": { "tags": [ "solution" @@ -1531,7 +1531,7 @@ }, { "cell_type": "markdown", - "id": "77638560", + "id": "81ea4131", "metadata": {}, "source": [ "

\n", @@ -1544,7 +1544,7 @@ }, { "cell_type": "markdown", - "id": "0e7c467c", + "id": "4fd3f863", "metadata": {}, "source": [ "

\n", @@ -1558,7 +1558,7 @@ }, { "cell_type": "markdown", - "id": "d5b37c02", + "id": "72c35c46", "metadata": {}, "source": [ "## Part 5: Importance of using the right training data\n", @@ -1570,7 +1570,7 @@ }, { "cell_type": "markdown", - "id": "4ab7521d", + "id": "98073861", "metadata": {}, "source": [ "First, we will write a function to add noise to the MNIST dataset, so that we can train a model to denoise it." @@ -1579,7 +1579,7 @@ { "cell_type": "code", "execution_count": null, - "id": "15340fcc", + "id": "8d114487", "metadata": {}, "outputs": [], "source": [ @@ -1592,7 +1592,7 @@ }, { "cell_type": "markdown", - "id": "bcb17b47", + "id": "0e18941a", "metadata": {}, "source": [ "Next we will visualize a couple MNIST examples with and without noise." @@ -1601,7 +1601,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3f4142ec", + "id": "e0a8600b", "metadata": {}, "outputs": [], "source": [ @@ -1630,7 +1630,7 @@ }, { "cell_type": "markdown", - "id": "32177f2e", + "id": "6b9f78a6", "metadata": {}, "source": [ "### UNet model\n", @@ -1640,7 +1640,7 @@ }, { "cell_type": "markdown", - "id": "0bde3d98", + "id": "bf5413d0", "metadata": {}, "source": [ "The training loop code is also provided here. It is similar to the code used to train the image classification model previously, but look it over to make sure there are no surprises." @@ -1649,7 +1649,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e642d956", + "id": "2b3698cd", "metadata": {}, "outputs": [], "source": [ @@ -1697,7 +1697,7 @@ }, { "cell_type": "markdown", - "id": "f82de800", + "id": "bf0121bd", "metadata": {}, "source": [ "Here we choose hyperparameters and initialize the model and data loaders." @@ -1706,7 +1706,7 @@ { "cell_type": "code", "execution_count": null, - "id": "3cf1768f", + "id": "f98bfc29", "metadata": {}, "outputs": [], "source": [ @@ -1744,7 +1744,7 @@ }, { "cell_type": "markdown", - "id": "c6491e06", + "id": "373b9235", "metadata": {}, "source": [ "Finally, we run the training loop!" @@ -1753,7 +1753,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a8ff968c", + "id": "1f174267", "metadata": {}, "outputs": [], "source": [ @@ -1764,7 +1764,7 @@ }, { "cell_type": "markdown", - "id": "2c0e657c", + "id": "696f7072", "metadata": {}, "source": [ "As before, we will visualize the training loss. If all went correctly, it should decrease from around 1.0 to less than 0.2." @@ -1773,7 +1773,7 @@ { "cell_type": "code", "execution_count": null, - "id": "a5f92989", + "id": "d831df5e", "metadata": { "lines_to_next_cell": 1 }, @@ -1789,7 +1789,7 @@ }, { "cell_type": "markdown", - "id": "1ff69a50", + "id": "cef6c1d9", "metadata": {}, "source": [ "### Check denoising performance\n", @@ -1800,7 +1800,7 @@ { "cell_type": "code", "execution_count": null, - "id": "1d3ff452", + "id": "93cb5ffa", "metadata": { "lines_to_next_cell": 1 }, @@ -1817,7 +1817,7 @@ { "cell_type": "code", "execution_count": null, - "id": "680d1a79", + "id": "8465bdfc", "metadata": { "lines_to_next_cell": 1 }, @@ -1843,7 +1843,7 @@ }, { "cell_type": "markdown", - "id": "dd293e3c", + "id": "064f938a", "metadata": {}, "source": [ "We pick 8 images to show:" @@ -1852,7 +1852,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d950e273", + "id": "170dbf3e", "metadata": {}, "outputs": [], "source": [ @@ -1862,7 +1862,7 @@ }, { "cell_type": "markdown", - "id": "5093a370", + "id": "ea1aff66", "metadata": {}, "source": [ "

\n", @@ -1873,7 +1873,7 @@ }, { "cell_type": "markdown", - "id": "9ee5481c", + "id": "e5ff2244", "metadata": { "tags": [ "solution" @@ -1887,7 +1887,7 @@ }, { "cell_type": "markdown", - "id": "7ea07946", + "id": "8817fd3d", "metadata": { "tags": [ "solution" @@ -1901,7 +1901,7 @@ }, { "cell_type": "markdown", - "id": "3e5bdd01", + "id": "5229fbd8", "metadata": {}, "source": [ "### Apply trained model on 'wrong' data\n", @@ -1911,7 +1911,7 @@ }, { "cell_type": "markdown", - "id": "08970f43", + "id": "6970de96", "metadata": {}, "source": [ "### Load the Fashion MNIST dataset\n", @@ -1922,7 +1922,7 @@ { "cell_type": "code", "execution_count": null, - "id": "e96ed5e7", + "id": "8cd71231", "metadata": {}, "outputs": [], "source": [ @@ -1943,7 +1943,7 @@ }, { "cell_type": "markdown", - "id": "f00758c2", + "id": "9f3463fc", "metadata": {}, "source": [ "Next we apply the denoising model we trained on the MNIST data to FashionMNIST, and visualize the results." @@ -1952,7 +1952,7 @@ { "cell_type": "code", "execution_count": null, - "id": "89b14b4b", + "id": "d8eb6ca9", "metadata": {}, "outputs": [], "source": [ @@ -1962,7 +1962,7 @@ }, { "cell_type": "markdown", - "id": "5e1870b6", + "id": "cd5b8116", "metadata": {}, "source": [ "

\n", @@ -1973,7 +1973,7 @@ }, { "cell_type": "markdown", - "id": "610c8a41", + "id": "de0df9a1", "metadata": { "tags": [ "solution" @@ -1987,7 +1987,7 @@ }, { "cell_type": "markdown", - "id": "f6ed5e00", + "id": "3210d7ac", "metadata": { "tags": [ "solution" @@ -2001,7 +2001,7 @@ }, { "cell_type": "markdown", - "id": "19f2c40c", + "id": "e8fd1056", "metadata": {}, "source": [ "

\n", @@ -2012,7 +2012,7 @@ }, { "cell_type": "markdown", - "id": "4274f603", + "id": "d6c69dea", "metadata": { "tags": [ "solution" @@ -2026,7 +2026,7 @@ }, { "cell_type": "markdown", - "id": "c5a2dfcc", + "id": "eb51387b", "metadata": { "tags": [ "solution" @@ -2041,7 +2041,7 @@ }, { "cell_type": "markdown", - "id": "fb0eeb74", + "id": "f76513da", "metadata": {}, "source": [ "### Train the denoiser on both MNIST and FashionMNIST\n", @@ -2052,7 +2052,7 @@ { "cell_type": "code", "execution_count": null, - "id": "eb150490", + "id": "24425a33", "metadata": {}, "outputs": [], "source": [ @@ -2089,7 +2089,7 @@ { "cell_type": "code", "execution_count": null, - "id": "ca64cf2e", + "id": "7b561f01", "metadata": {}, "outputs": [], "source": [ @@ -2100,7 +2100,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8574e737", + "id": "4bbc903b", "metadata": {}, "outputs": [], "source": [ @@ -2110,7 +2110,7 @@ }, { "cell_type": "markdown", - "id": "84a7865c", + "id": "05c96c6f", "metadata": {}, "source": [ "

\n", @@ -2121,7 +2121,7 @@ }, { "cell_type": "markdown", - "id": "59ececbf", + "id": "ab24cd58", "metadata": { "lines_to_next_cell": 0, "tags": [ @@ -2139,7 +2139,7 @@ }, { "cell_type": "markdown", - "id": "9bb4a705", + "id": "ea773de2", "metadata": {}, "source": [ "### Train the denoiser on both MNIST and FashionMNIST, shuffling the training data\n", @@ -2150,7 +2150,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d229e0fa", + "id": "59f373b2", "metadata": {}, "outputs": [], "source": [ @@ -2187,7 +2187,7 @@ { "cell_type": "code", "execution_count": null, - "id": "2085c32f", + "id": "76162517", "metadata": {}, "outputs": [], "source": [ @@ -2198,7 +2198,7 @@ { "cell_type": "code", "execution_count": null, - "id": "631c1b64", + "id": "3f38e5ae", "metadata": {}, "outputs": [], "source": [ @@ -2208,7 +2208,7 @@ }, { "cell_type": "markdown", - "id": "83bffaba", + "id": "42840fdf", "metadata": {}, "source": [ "

\n", @@ -2219,7 +2219,7 @@ }, { "cell_type": "markdown", - "id": "35e0a667", + "id": "330c1a93", "metadata": { "tags": [ "solution" @@ -2233,7 +2233,7 @@ }, { "cell_type": "markdown", - "id": "1b7c9fcf", + "id": "506aa6ce", "metadata": {}, "source": [ "\n", @@ -2247,7 +2247,7 @@ }, { "cell_type": "markdown", - "id": "c258e7ae", + "id": "7d29b67d", "metadata": {}, "source": [ "\n", @@ -2261,7 +2261,7 @@ }, { "cell_type": "markdown", - "id": "11700dbd", + "id": "e837cbed", "metadata": {}, "source": [] }