diff --git a/BE2_GAN_and_cGAN.ipynb b/BE2_GAN_and_cGAN.ipynb index 7243c8909272f2e776695baf70e3aea2aa9b3aef..8d8e66543f204de4f012ed28d71188d75a917e29 100644 --- a/BE2_GAN_and_cGAN.ipynb +++ b/BE2_GAN_and_cGAN.ipynb @@ -69,15 +69,67 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": { "colab": {}, "colab_type": "code", "id": "sIL7UvYAZx6L" }, - "outputs": [], + "outputs": [ + { + "ename": "ModuleNotFoundError", + "evalue": "No module named 'torch'", + "output_type": "error", + "traceback": [ + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[1;31mModuleNotFoundError\u001b[0m Traceback (most recent call last)", + "\u001b[1;32m~\\AppData\\Local\\Temp\\ipykernel_27176\\1645866687.py\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 6\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mos\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 7\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mrandom\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 8\u001b[1;33m \u001b[1;32mimport\u001b[0m \u001b[0mtorch\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 9\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mtorch\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnn\u001b[0m \u001b[1;32mas\u001b[0m \u001b[0mnn\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 10\u001b[0m \u001b[1;32mimport\u001b[0m \u001b[0mtorch\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mnn\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mparallel\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n", + "\u001b[1;31mModuleNotFoundError\u001b[0m: No module named 'torch'" + ] + } + ], "source": [ - "#TO DO: your code here to adapt the code from the tutorial to experiment on MNIST dataset" + "#TO DO: your code here to adapt the code from the tutorial to experiment on MNIST dataset\n", + "\n", + "from __future__ import print_function\n", + "#%matplotlib inline\n", + "import argparse\n", + "import os\n", + "import random\n", + "import torch\n", + "import torch.nn as nn\n", + "import torch.nn.parallel\n", + "import torch.backends.cudnn as cudnn\n", + "import torch.optim as optim\n", + "import torch.utils.data\n", + "import torchvision.datasets as dset\n", + "import torchvision.transforms as transforms\n", + "import torchvision.utils as vutils\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import matplotlib.animation as animation\n", + "from IPython.display import HTML\n", + "\n", + "# Set random seed for reproducibility\n", + "manualSeed = 999\n", + "#manualSeed = random.randint(1, 10000) # use if you want new results\n", + "print(\"Random Seed: \", manualSeed)\n", + "random.seed(manualSeed)\n", + "torch.manual_seed(manualSeed)\n", + "\n", + "# Create the generator\n", + "netG = Generator(ngpu).to(device)\n", + "\n", + "# Handle multi-gpu if desired\n", + "if (device.type == 'cuda') and (ngpu > 1):\n", + " netG = nn.DataParallel(netG, list(range(ngpu)))\n", + "\n", + "# Apply the weights_init function to randomly initialize all weights\n", + "# to mean=0, stdev=0.02.\n", + "netG.apply(weights_init)\n", + "\n", + "# Print the model\n", + "print(netG)" ] }, { @@ -1225,7 +1277,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.8" + "version": "3.9.13" } }, "nbformat": 4, diff --git a/README.md b/README.md index 57884980d12716147ef767baaee44c3afe0e851a..44b0f1bd63230afdec9977e131472fc701c8e436 100644 --- a/README.md +++ b/README.md @@ -4,4 +4,10 @@ We recommand to use the notebook (.ipynb) but the Python script (.py) is also pr # How to submit your Work ? -This work must be done individually. The expected output is a repository named gan-cgan on https://gitlab.ec-lyon.fr. It must contain your notebook (or python files) and a README.md file that explains briefly the successive steps of the project. The last commit is due before 11:59 pm on Wednesday, March 29, 2023. Subsequent commits will not be considered. \ No newline at end of file +This work must be done individually. The expected output is a repository named gan-cgan on https://gitlab.ec-lyon.fr. It must contain your notebook (or python files) and a README.md file that explains briefly the successive steps of the project. The last commit is due before 11:59 pm on Wednesday, March 29, 2023. Subsequent commits will not be considered. + + +# DCGAN + +To reduce the time of execution we use Google Colab GPU; +The MNIST dataset uses black and white images so the first step is to change the number of channels for 1 (in the tutorial was 3 because of RGB data used);