{"cells": [{"cell_type": "markdown", "id": "0dd94757", "metadata": {"papermill": {"duration": 0.027135, "end_time": "2022-04-28T08:15:39.603883", "exception": false, "start_time": "2022-04-28T08:15:39.576748", "status": "completed"}, "tags": []}, "source": ["\n", "# PyTorch Lightning Basic GAN Tutorial\n", "\n", "* **Author:** PL team\n", "* **License:** CC BY-SA\n", "* **Generated:** 2022-04-28T08:05:27.455055\n", "\n", "How to train a GAN!\n", "\n", "Main takeaways:\n", "1. Generator and discriminator are arbitrary PyTorch modules.\n", "2. training_step does both the generator and discriminator training.\n", "\n", "\n", "---\n", "Open in [{height=\"20px\" width=\"117px\"}](https://colab.research.google.com/github/PytorchLightning/lightning-tutorials/blob/publication/.notebooks/lightning_examples/basic-gan.ipynb)\n", "\n", "Give us a \u2b50 [on Github](https://www.github.com/PytorchLightning/pytorch-lightning/)\n", "| Check out [the documentation](https://pytorch-lightning.readthedocs.io/en/stable/)\n", "| Join us [on Slack](https://www.pytorchlightning.ai/community)"]}, {"cell_type": "markdown", "id": "65cc38cc", "metadata": {"papermill": {"duration": 0.025408, "end_time": "2022-04-28T08:15:39.655445", "exception": false, "start_time": "2022-04-28T08:15:39.630037", "status": "completed"}, "tags": []}, "source": ["## Setup\n", "This notebook requires some packages besides pytorch-lightning."]}, {"cell_type": "code", "execution_count": 1, "id": "90f18904", "metadata": {"colab": {}, "colab_type": "code", "execution": {"iopub.execute_input": "2022-04-28T08:15:39.712634Z", "iopub.status.busy": "2022-04-28T08:15:39.712091Z", "iopub.status.idle": "2022-04-28T08:15:42.873584Z", "shell.execute_reply": "2022-04-28T08:15:42.874015Z"}, "id": "LfrJLKPFyhsK", "lines_to_next_cell": 0, "papermill": {"duration": 3.194458, "end_time": "2022-04-28T08:15:42.874280", "exception": false, "start_time": "2022-04-28T08:15:39.679822", "status": "completed"}, "tags": []}, "outputs": [{"name": "stdout", "output_type": "stream", "text": ["\u001b[33mWARNING: You are using pip version 21.3.1; however, version 22.0.4 is available.\r\n", "You should consider upgrading via the '/usr/bin/python3.8 -m pip install --upgrade pip' command.\u001b[0m\r\n"]}], "source": ["! pip install --quiet \"torchvision\" \"pytorch-lightning>=1.4\" \"torchmetrics>=0.6\" \"ipython[notebook]\" \"torch>=1.6, <1.9\""]}, {"cell_type": "code", "execution_count": 2, "id": "84c33dee", "metadata": {"execution": {"iopub.execute_input": "2022-04-28T08:15:42.931853Z", "iopub.status.busy": "2022-04-28T08:15:42.931342Z", "iopub.status.idle": "2022-04-28T08:15:44.267051Z", "shell.execute_reply": "2022-04-28T08:15:44.267488Z"}, "papermill": {"duration": 1.366233, "end_time": "2022-04-28T08:15:44.267664", "exception": false, "start_time": "2022-04-28T08:15:42.901431", "status": "completed"}, "tags": []}, "outputs": [], "source": ["import os\n", "\n", "import numpy as np\n", "import torch\n", "import torch.nn as nn\n", "import torch.nn.functional as F\n", "import torchvision\n", "import torchvision.transforms as transforms\n", "from pytorch_lightning import LightningDataModule, LightningModule, Trainer\n", "from pytorch_lightning.callbacks.progress import TQDMProgressBar\n", "from torch.utils.data import DataLoader, random_split\n", "from torchvision.datasets import MNIST\n", "\n", "PATH_DATASETS = os.environ.get(\"PATH_DATASETS\", \".\")\n", "BATCH_SIZE = 256 if torch.cuda.is_available() else 64\n", "NUM_WORKERS = int(os.cpu_count() / 2)"]}, {"cell_type": "markdown", "id": "a73ed144", "metadata": {"lines_to_next_cell": 2, "papermill": {"duration": 0.025413, "end_time": "2022-04-28T08:15:44.319631", "exception": false, "start_time": "2022-04-28T08:15:44.294218", "status": "completed"}, "tags": []}, "source": ["### MNIST DataModule\n", "\n", "Below, we define a DataModule for the MNIST Dataset. To learn more about DataModules, check out our tutorial\n", "on them or see the [latest docs](https://pytorch-lightning.readthedocs.io/en/stable/extensions/datamodules.html)."]}, {"cell_type": "code", "execution_count": 3, "id": "d934ebd0", "metadata": {"execution": {"iopub.execute_input": "2022-04-28T08:15:44.381766Z", "iopub.status.busy": "2022-04-28T08:15:44.381248Z", "iopub.status.idle": "2022-04-28T08:15:44.383180Z", "shell.execute_reply": "2022-04-28T08:15:44.383565Z"}, "lines_to_next_cell": 2, "papermill": {"duration": 0.038552, "end_time": "2022-04-28T08:15:44.383708", "exception": false, "start_time": "2022-04-28T08:15:44.345156", "status": "completed"}, "tags": []}, "outputs": [], "source": ["class MNISTDataModule(LightningDataModule):\n", " def __init__(\n", " self,\n", " data_dir: str = PATH_DATASETS,\n", " batch_size: int = BATCH_SIZE,\n", " num_workers: int = NUM_WORKERS,\n", " ):\n", " super().__init__()\n", " self.data_dir = data_dir\n", " self.batch_size = batch_size\n", " self.num_workers = num_workers\n", "\n", " self.transform = transforms.Compose(\n", " [\n", " transforms.ToTensor(),\n", " transforms.Normalize((0.1307,), (0.3081,)),\n", " ]\n", " )\n", "\n", " # self.dims is returned when you call dm.size()\n", " # Setting default dims here because we know them.\n", " # Could optionally be assigned dynamically in dm.setup()\n", " self.dims = (1, 28, 28)\n", " self.num_classes = 10\n", "\n", " def prepare_data(self):\n", " # download\n", " MNIST(self.data_dir, train=True, download=True)\n", " MNIST(self.data_dir, train=False, download=True)\n", "\n", " def setup(self, stage=None):\n", " # Assign train/val datasets for use in dataloaders\n", " if stage == \"fit\" or stage is None:\n", " mnist_full = MNIST(self.data_dir, train=True, transform=self.transform)\n", " self.mnist_train, self.mnist_val = random_split(mnist_full, [55000, 5000])\n", "\n", " # Assign test dataset for use in dataloader(s)\n", " if stage == \"test\" or stage is None:\n", " self.mnist_test = MNIST(self.data_dir, train=False, transform=self.transform)\n", "\n", " def train_dataloader(self):\n", " return DataLoader(\n", " self.mnist_train,\n", " batch_size=self.batch_size,\n", " num_workers=self.num_workers,\n", " )\n", "\n", " def val_dataloader(self):\n", " return DataLoader(self.mnist_val, batch_size=self.batch_size, num_workers=self.num_workers)\n", "\n", " def test_dataloader(self):\n", " return DataLoader(self.mnist_test, batch_size=self.batch_size, num_workers=self.num_workers)"]}, {"cell_type": "markdown", "id": "4f6cb71f", "metadata": {"lines_to_next_cell": 2, "papermill": {"duration": 0.025758, "end_time": "2022-04-28T08:15:44.435534", "exception": false, "start_time": "2022-04-28T08:15:44.409776", "status": "completed"}, "tags": []}, "source": ["### A. Generator"]}, {"cell_type": "code", "execution_count": 4, "id": "d2d1366a", "metadata": {"execution": {"iopub.execute_input": "2022-04-28T08:15:44.494872Z", "iopub.status.busy": "2022-04-28T08:15:44.494360Z", "iopub.status.idle": "2022-04-28T08:15:44.496256Z", "shell.execute_reply": "2022-04-28T08:15:44.496659Z"}, "lines_to_next_cell": 2, "papermill": {"duration": 0.035038, "end_time": "2022-04-28T08:15:44.496797", "exception": false, "start_time": "2022-04-28T08:15:44.461759", "status": "completed"}, "tags": []}, "outputs": [], "source": ["class Generator(nn.Module):\n", " def __init__(self, latent_dim, img_shape):\n", " super().__init__()\n", " self.img_shape = img_shape\n", "\n", " def block(in_feat, out_feat, normalize=True):\n", " layers = [nn.Linear(in_feat, out_feat)]\n", " if normalize:\n", " layers.append(nn.BatchNorm1d(out_feat, 0.8))\n", " layers.append(nn.LeakyReLU(0.2, inplace=True))\n", " return layers\n", "\n", " self.model = nn.Sequential(\n", " *block(latent_dim, 128, normalize=False),\n", " *block(128, 256),\n", " *block(256, 512),\n", " *block(512, 1024),\n", " nn.Linear(1024, int(np.prod(img_shape))),\n", " nn.Tanh(),\n", " )\n", "\n", " def forward(self, z):\n", " img = self.model(z)\n", " img = img.view(img.size(0), *self.img_shape)\n", " return img"]}, {"cell_type": "markdown", "id": "289f3e57", "metadata": {"lines_to_next_cell": 2, "papermill": {"duration": 0.02628, "end_time": "2022-04-28T08:15:44.549244", "exception": false, "start_time": "2022-04-28T08:15:44.522964", "status": "completed"}, "tags": []}, "source": ["### B. Discriminator"]}, {"cell_type": "code", "execution_count": 5, "id": "93265b6e", "metadata": {"execution": {"iopub.execute_input": "2022-04-28T08:15:44.605718Z", "iopub.status.busy": "2022-04-28T08:15:44.602976Z", "iopub.status.idle": "2022-04-28T08:15:44.607531Z", "shell.execute_reply": "2022-04-28T08:15:44.607933Z"}, "lines_to_next_cell": 2, "papermill": {"duration": 0.032777, "end_time": "2022-04-28T08:15:44.608063", "exception": false, "start_time": "2022-04-28T08:15:44.575286", "status": "completed"}, "tags": []}, "outputs": [], "source": ["class Discriminator(nn.Module):\n", " def __init__(self, img_shape):\n", " super().__init__()\n", "\n", " self.model = nn.Sequential(\n", " nn.Linear(int(np.prod(img_shape)), 512),\n", " nn.LeakyReLU(0.2, inplace=True),\n", " nn.Linear(512, 256),\n", " nn.LeakyReLU(0.2, inplace=True),\n", " nn.Linear(256, 1),\n", " nn.Sigmoid(),\n", " )\n", "\n", " def forward(self, img):\n", " img_flat = img.view(img.size(0), -1)\n", " validity = self.model(img_flat)\n", "\n", " return validity"]}, {"cell_type": "markdown", "id": "85f38a4f", "metadata": {"lines_to_next_cell": 2, "papermill": {"duration": 0.025517, "end_time": "2022-04-28T08:15:44.659491", "exception": false, "start_time": "2022-04-28T08:15:44.633974", "status": "completed"}, "tags": []}, "source": ["### C. GAN\n", "\n", "#### A couple of cool features to check out in this example...\n", "\n", " - We use `some_tensor.type_as(another_tensor)` to make sure we initialize new tensors on the right device (i.e. GPU, CPU).\n", " - Lightning will put your dataloader data on the right device automatically\n", " - In this example, we pull from latent dim on the fly, so we need to dynamically add tensors to the right device.\n", " - `type_as` is the way we recommend to do this.\n", " - This example shows how to use multiple dataloaders in your `LightningModule`."]}, {"cell_type": "code", "execution_count": 6, "id": "49938e43", "metadata": {"execution": {"iopub.execute_input": "2022-04-28T08:15:44.723994Z", "iopub.status.busy": "2022-04-28T08:15:44.719048Z", "iopub.status.idle": "2022-04-28T08:15:44.725850Z", "shell.execute_reply": "2022-04-28T08:15:44.726252Z"}, "papermill": {"duration": 0.040264, "end_time": "2022-04-28T08:15:44.726384", "exception": false, "start_time": "2022-04-28T08:15:44.686120", "status": "completed"}, "tags": []}, "outputs": [], "source": ["class GAN(LightningModule):\n", " def __init__(\n", " self,\n", " channels,\n", " width,\n", " height,\n", " latent_dim: int = 100,\n", " lr: float = 0.0002,\n", " b1: float = 0.5,\n", " b2: float = 0.999,\n", " batch_size: int = BATCH_SIZE,\n", " **kwargs,\n", " ):\n", " super().__init__()\n", " self.save_hyperparameters()\n", "\n", " # networks\n", " data_shape = (channels, width, height)\n", " self.generator = Generator(latent_dim=self.hparams.latent_dim, img_shape=data_shape)\n", " self.discriminator = Discriminator(img_shape=data_shape)\n", "\n", " self.validation_z = torch.randn(8, self.hparams.latent_dim)\n", "\n", " self.example_input_array = torch.zeros(2, self.hparams.latent_dim)\n", "\n", " def forward(self, z):\n", " return self.generator(z)\n", "\n", " def adversarial_loss(self, y_hat, y):\n", " return F.binary_cross_entropy(y_hat, y)\n", "\n", " def training_step(self, batch, batch_idx, optimizer_idx):\n", " imgs, _ = batch\n", "\n", " # sample noise\n", " z = torch.randn(imgs.shape[0], self.hparams.latent_dim)\n", " z = z.type_as(imgs)\n", "\n", " # train generator\n", " if optimizer_idx == 0:\n", "\n", " # generate images\n", " self.generated_imgs = self(z)\n", "\n", " # log sampled images\n", " sample_imgs = self.generated_imgs[:6]\n", " grid = torchvision.utils.make_grid(sample_imgs)\n", " self.logger.experiment.add_image(\"generated_images\", grid, 0)\n", "\n", " # ground truth result (ie: all fake)\n", " # put on GPU because we created this tensor inside training_loop\n", " valid = torch.ones(imgs.size(0), 1)\n", " valid = valid.type_as(imgs)\n", "\n", " # adversarial loss is binary cross-entropy\n", " g_loss = self.adversarial_loss(self.discriminator(self(z)), valid)\n", " self.log(\"g_loss\", g_loss, prog_bar=True)\n", " return g_loss\n", "\n", " # train discriminator\n", " if optimizer_idx == 1:\n", " # Measure discriminator's ability to classify real from generated samples\n", "\n", " # how well can it label as real?\n", " valid = torch.ones(imgs.size(0), 1)\n", " valid = valid.type_as(imgs)\n", "\n", " real_loss = self.adversarial_loss(self.discriminator(imgs), valid)\n", "\n", " # how well can it label as fake?\n", " fake = torch.zeros(imgs.size(0), 1)\n", " fake = fake.type_as(imgs)\n", "\n", " fake_loss = self.adversarial_loss(self.discriminator(self(z).detach()), fake)\n", "\n", " # discriminator loss is the average of these\n", " d_loss = (real_loss + fake_loss) / 2\n", " self.log(\"d_loss\", d_loss, prog_bar=True)\n", " return d_loss\n", "\n", " def configure_optimizers(self):\n", " lr = self.hparams.lr\n", " b1 = self.hparams.b1\n", " b2 = self.hparams.b2\n", "\n", " opt_g = torch.optim.Adam(self.generator.parameters(), lr=lr, betas=(b1, b2))\n", " opt_d = torch.optim.Adam(self.discriminator.parameters(), lr=lr, betas=(b1, b2))\n", " return [opt_g, opt_d], []\n", "\n", " def on_validation_epoch_end(self):\n", " z = self.validation_z.type_as(self.generator.model[0].weight)\n", "\n", " # log sampled images\n", " sample_imgs = self(z)\n", " grid = torchvision.utils.make_grid(sample_imgs)\n", " self.logger.experiment.add_image(\"generated_images\", grid, self.current_epoch)"]}, {"cell_type": "code", "execution_count": 7, "id": "6db4ca69", "metadata": {"execution": {"iopub.execute_input": "2022-04-28T08:15:44.782707Z", "iopub.status.busy": "2022-04-28T08:15:44.782183Z", "iopub.status.idle": "2022-04-28T08:16:09.805648Z", "shell.execute_reply": "2022-04-28T08:16:09.806078Z"}, "papermill": {"duration": 25.053878, "end_time": "2022-04-28T08:16:09.806312", "exception": false, "start_time": "2022-04-28T08:15:44.752434", "status": "completed"}, "tags": []}, "outputs": [{"name": "stderr", "output_type": "stream", "text": ["/home/AzDevOps_azpcontainer/.local/lib/python3.8/site-packages/pytorch_lightning/core/datamodule.py:149: LightningDeprecationWarning: DataModule property `dims` was deprecated in v1.5 and will be removed in v1.7.\n", " rank_zero_deprecation(\"DataModule property `dims` was deprecated in v1.5 and will be removed in v1.7.\")\n", "/home/AzDevOps_azpcontainer/.local/lib/python3.8/site-packages/pytorch_lightning/core/datamodule.py:158: LightningDeprecationWarning: DataModule property `size` was deprecated in v1.5 and will be removed in v1.7.\n", " rank_zero_deprecation(\"DataModule property `size` was deprecated in v1.5 and will be removed in v1.7.\")\n", "/home/AzDevOps_azpcontainer/.local/lib/python3.8/site-packages/pytorch_lightning/core/datamodule.py:144: LightningDeprecationWarning: DataModule property `dims` was deprecated in v1.5 and will be removed in v1.7.\n", " rank_zero_deprecation(\"DataModule property `dims` was deprecated in v1.5 and will be removed in v1.7.\")\n", "GPU available: True, used: True\n"]}, {"name": "stderr", "output_type": "stream", "text": ["TPU available: False, using: 0 TPU cores\n"]}, {"name": "stderr", "output_type": "stream", "text": ["IPU available: False, using: 0 IPUs\n"]}, {"name": "stderr", "output_type": "stream", "text": ["HPU available: False, using: 0 HPUs\n"]}, {"name": "stdout", "output_type": "stream", "text": ["Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz\n", "Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz to /__w/1/s/.datasets/MNIST/raw/train-images-idx3-ubyte.gz\n"]}, {"name": "stderr", "output_type": "stream", "text": ["/home/AzDevOps_azpcontainer/.local/lib/python3.8/site-packages/pytorch_lightning/trainer/configuration_validator.py:131: UserWarning: You passed in a `val_dataloader` but have no `validation_step`. Skipping val loop.\n", " rank_zero_warn(\"You passed in a `val_dataloader` but have no `validation_step`. Skipping val loop.\")\n"]}, {"data": {"application/vnd.jupyter.widget-view+json": {"model_id": "3aefbeb6c099483085a061188b504cd5", "version_major": 2, "version_minor": 0}, "text/plain": [" 0%| | 0/9912422 [00:00, ?it/s]"]}, "metadata": {}, "output_type": "display_data"}, {"name": "stdout", "output_type": "stream", "text": ["Extracting /__w/1/s/.datasets/MNIST/raw/train-images-idx3-ubyte.gz to /__w/1/s/.datasets/MNIST/raw\n"]}, {"name": "stdout", "output_type": "stream", "text": ["\n", "Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz\n", "Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz to /__w/1/s/.datasets/MNIST/raw/train-labels-idx1-ubyte.gz\n"]}, {"data": {"application/vnd.jupyter.widget-view+json": {"model_id": "232d6619ec0847f6876d37ac9a96d521", "version_major": 2, "version_minor": 0}, "text/plain": [" 0%| | 0/28881 [00:00, ?it/s]"]}, "metadata": {}, "output_type": "display_data"}, {"name": "stdout", "output_type": "stream", "text": ["Extracting /__w/1/s/.datasets/MNIST/raw/train-labels-idx1-ubyte.gz to /__w/1/s/.datasets/MNIST/raw\n", "\n", "Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz\n", "Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz to /__w/1/s/.datasets/MNIST/raw/t10k-images-idx3-ubyte.gz\n"]}, {"data": {"application/vnd.jupyter.widget-view+json": {"model_id": "c071aa1bfc0a4442a6b87368e704db24", "version_major": 2, "version_minor": 0}, "text/plain": [" 0%| | 0/1648877 [00:00, ?it/s]"]}, "metadata": {}, "output_type": "display_data"}, {"name": "stdout", "output_type": "stream", "text": ["Extracting /__w/1/s/.datasets/MNIST/raw/t10k-images-idx3-ubyte.gz to /__w/1/s/.datasets/MNIST/raw\n", "\n", "Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz\n"]}, {"name": "stdout", "output_type": "stream", "text": ["Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz to /__w/1/s/.datasets/MNIST/raw/t10k-labels-idx1-ubyte.gz\n"]}, {"data": {"application/vnd.jupyter.widget-view+json": {"model_id": "c88645ccfa1c48fc81d4c2dcc515b2d6", "version_major": 2, "version_minor": 0}, "text/plain": [" 0%| | 0/4542 [00:00, ?it/s]"]}, "metadata": {}, "output_type": "display_data"}, {"name": "stdout", "output_type": "stream", "text": ["Extracting /__w/1/s/.datasets/MNIST/raw/t10k-labels-idx1-ubyte.gz to /__w/1/s/.datasets/MNIST/raw\n", "\n", "Processing...\n"]}, {"name": "stderr", "output_type": "stream", "text": ["/home/AzDevOps_azpcontainer/.local/lib/python3.8/site-packages/torchvision/datasets/mnist.py:502: UserWarning: The given NumPy array is not writeable, and PyTorch does not support non-writeable tensors. This means you can write to the underlying (supposedly non-writeable) NumPy array using the tensor. You may want to copy the array to protect its data or make it writeable before converting it to a tensor. This type of warning will be suppressed for the rest of this program. (Triggered internally at /pytorch/torch/csrc/utils/tensor_numpy.cpp:143.)\n", " return torch.from_numpy(parsed.astype(m[2], copy=False)).view(*s)\n", "Missing logger folder: /__w/1/s/lightning_logs\n"]}, {"name": "stdout", "output_type": "stream", "text": ["Done!\n"]}, {"name": "stderr", "output_type": "stream", "text": ["LOCAL_RANK: 0 - CUDA_VISIBLE_DEVICES: [0,1]\n"]}, {"name": "stderr", "output_type": "stream", "text": ["\n", " | Name | Type | Params | In sizes | Out sizes \n", "----------------------------------------------------------------------------\n", "0 | generator | Generator | 1.5 M | [2, 100] | [2, 1, 28, 28]\n", "1 | discriminator | Discriminator | 533 K | ? | ? \n", "----------------------------------------------------------------------------\n", "2.0 M Trainable params\n", "0 Non-trainable params\n", "2.0 M Total params\n", "8.174 Total estimated model params size (MB)\n"]}, {"data": {"application/vnd.jupyter.widget-view+json": {"model_id": "8b91068235b947fdb6735c11f5fa0582", "version_major": 2, "version_minor": 0}, "text/plain": ["Training: 0it [00:00, ?it/s]"]}, "metadata": {}, "output_type": "display_data"}], "source": ["dm = MNISTDataModule()\n", "model = GAN(*dm.size())\n", "trainer = Trainer(\n", " accelerator=\"auto\",\n", " devices=1 if torch.cuda.is_available() else None, # limiting got iPython runs\n", " max_epochs=5,\n", " callbacks=[TQDMProgressBar(refresh_rate=20)],\n", ")\n", "trainer.fit(model, dm)"]}, {"cell_type": "code", "execution_count": 8, "id": "0f6517d8", "metadata": {"execution": {"iopub.execute_input": "2022-04-28T08:16:09.900751Z", "iopub.status.busy": "2022-04-28T08:16:09.900239Z", "iopub.status.idle": "2022-04-28T08:16:11.449523Z", "shell.execute_reply": "2022-04-28T08:16:11.449934Z"}, "papermill": {"duration": 1.598576, "end_time": "2022-04-28T08:16:11.450102", "exception": false, "start_time": "2022-04-28T08:16:09.851526", "status": "completed"}, "tags": []}, "outputs": [{"data": {"text/html": ["\n", " \n", " \n", " "], "text/plain": [""]}, "metadata": {}, "output_type": "display_data"}], "source": ["# Start tensorboard.\n", "%load_ext tensorboard\n", "%tensorboard --logdir lightning_logs/"]}, {"cell_type": "markdown", "id": "e41a029e", "metadata": {"papermill": {"duration": 0.04553, "end_time": "2022-04-28T08:16:11.542740", "exception": false, "start_time": "2022-04-28T08:16:11.497210", "status": "completed"}, "tags": []}, "source": ["## Congratulations - Time to Join the Community!\n", "\n", "Congratulations on completing this notebook tutorial! If you enjoyed this and would like to join the Lightning\n", "movement, you can do so in the following ways!\n", "\n", "### Star [Lightning](https://github.com/PyTorchLightning/pytorch-lightning) on GitHub\n", "The easiest way to help our community is just by starring the GitHub repos! This helps raise awareness of the cool\n", "tools we're building.\n", "\n", "### Join our [Slack](https://www.pytorchlightning.ai/community)!\n", "The best way to keep up to date on the latest advancements is to join our community! Make sure to introduce yourself\n", "and share your interests in `#general` channel\n", "\n", "\n", "### Contributions !\n", "The best way to contribute to our community is to become a code contributor! At any time you can go to\n", "[Lightning](https://github.com/PyTorchLightning/pytorch-lightning) or [Bolt](https://github.com/PyTorchLightning/lightning-bolts)\n", "GitHub Issues page and filter for \"good first issue\".\n", "\n", "* [Lightning good first issue](https://github.com/PyTorchLightning/pytorch-lightning/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)\n", "* [Bolt good first issue](https://github.com/PyTorchLightning/lightning-bolts/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22)\n", "* You can also contribute your own notebooks with useful examples !\n", "\n", "### Great thanks from the entire Pytorch Lightning Team for your interest !\n", "\n", "[{height=\"60px\" width=\"240px\"}](https://pytorchlightning.ai)"]}, {"cell_type": "raw", "metadata": {"raw_mimetype": "text/restructuredtext"}, "source": [".. customcarditem::\n", " :header: PyTorch Lightning Basic GAN Tutorial\n", " :card_description: How to train a GAN! Main takeaways: 1. Generator and discriminator are arbitrary PyTorch modules. 2. training_step does both the generator and discriminator training.\n", " :tags: Image,GPU/TPU,Lightning-Examples"]}], "metadata": {"jupytext": {"cell_metadata_filter": "colab_type,id,colab,-all", "formats": "ipynb,py:percent", "main_language": "python"}, "language_info": {"codemirror_mode": {"name": "ipython", "version": 3}, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.12"}, "papermill": {"default_parameters": {}, "duration": 34.258109, "end_time": "2022-04-28T08:16:12.298676", "environment_variables": {}, "exception": null, "input_path": "lightning_examples/basic-gan/gan.ipynb", "output_path": ".notebooks/lightning_examples/basic-gan.ipynb", "parameters": {}, "start_time": "2022-04-28T08:15:38.040567", "version": "2.3.4"}, "widgets": {"application/vnd.jupyter.widget-state+json": {"state": {"06ac5cbee49d441cb827fede0061f716": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_2df5c08474eb410596a79e45a462a491", "max": 1648877.0, "min": 0.0, "orientation": "horizontal", "style": "IPY_MODEL_da557cc64d5e48f38ab34c38c093da91", "value": 1648877.0}}, "072004c709c349aeab16094d2a5e1e7e": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_2d5828368aba474fbf4d2629e4b4c482", "max": 9912422.0, "min": 0.0, "orientation": "horizontal", "style": "IPY_MODEL_3b6778bf4d0f4229aff63e6675822995", "value": 9912422.0}}, "0be9aa37a2154a4b9f1636e52bd0e7a5": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "11fb3f9ce6474e908e0f86091716971c": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "1410455aa3bf4852b8237cafeec87df8": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "15736e9ae26f4850b46ca158119b910d": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_1410455aa3bf4852b8237cafeec87df8", "placeholder": "\u200b", "style": "IPY_MODEL_e74acd449f0d481c8bb617604a29bf17", "value": " 9913344/? [00:00<00:00, 121907792.42it/s]"}}, "1b3f7549a63340148dc5eaf231f795ad": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "206de8041922434586fe9e6e86eab771": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": "inline-flex", "flex": null, "flex_flow": "row wrap", "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": "100%"}}, "232d6619ec0847f6876d37ac9a96d521": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": ["IPY_MODEL_38eb9950a4ed4438942e2bdd7d753767", "IPY_MODEL_7d405034d40b4fbea7a219ab49fb40c7", "IPY_MODEL_ab51db5ce0be46298012e0e4c0c55418"], "layout": "IPY_MODEL_667f69d7c327421f87d58d9b92a7c3e5"}}, "27ec4bd412624bb897df9de324e35326": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_4030524b257846588398a72632799b52", "max": 4542.0, "min": 0.0, "orientation": "horizontal", "style": "IPY_MODEL_b6dfd3d280c34161a381f31c5ecb0730", "value": 4542.0}}, "2c3e35427a8443d194a39c6a848e1bcd": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_404e1ef6666947b29ba0545ddad34ac9", "placeholder": "\u200b", "style": "IPY_MODEL_634c1d4d11bf4fd7a7098f12b30cf644", "value": ""}}, "2d5828368aba474fbf4d2629e4b4c482": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "2df5c08474eb410596a79e45a462a491": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "31ba14611cff4b04a92fa1288b37c5fb": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "34802630367846c68da08e9091be15a1": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": "2", "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "38eb9950a4ed4438942e2bdd7d753767": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_9d41038f33ea4e92894a6c7e5fa8c975", "placeholder": "\u200b", "style": "IPY_MODEL_9ab4e3e009ba45169ea9e90d45f0abbe", "value": ""}}, "393f97101dfa44f0b96c47b9df15999f": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": ""}}, "3aefbeb6c099483085a061188b504cd5": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": ["IPY_MODEL_68a5763a0aad4b079d91279a3fe8fe8a", "IPY_MODEL_072004c709c349aeab16094d2a5e1e7e", "IPY_MODEL_15736e9ae26f4850b46ca158119b910d"], "layout": "IPY_MODEL_3dacf625da4d47cd9426f44fd6da7723"}}, "3b6778bf4d0f4229aff63e6675822995": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": ""}}, "3dacf625da4d47cd9426f44fd6da7723": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "3f600402fad44322af467d05180651bb": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": ""}}, "4030524b257846588398a72632799b52": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "404e1ef6666947b29ba0545ddad34ac9": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "5261d8cc2c5e49a3b96499a833231a48": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_a3a4cf5a544d4366b4983961dfdb3e33", "placeholder": "\u200b", "style": "IPY_MODEL_61ff90e70d0f4174ba4e3431bfef42df", "value": " 215/215 [00:21<00:00, 10.21it/s, loss=2.56, v_num=0, g_loss=4.890, d_loss=0.072]"}}, "61ff90e70d0f4174ba4e3431bfef42df": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": ""}}, "634c1d4d11bf4fd7a7098f12b30cf644": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": ""}}, "667f69d7c327421f87d58d9b92a7c3e5": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "68a5763a0aad4b079d91279a3fe8fe8a": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_11fb3f9ce6474e908e0f86091716971c", "placeholder": "\u200b", "style": "IPY_MODEL_d0ecfa8069034fb1a59d8f07df5e8ffd", "value": ""}}, "6c4419068928469b8786215c65fae984": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "7d405034d40b4fbea7a219ab49fb40c7": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_a843b546527243cdb4aa022400fbc626", "max": 28881.0, "min": 0.0, "orientation": "horizontal", "style": "IPY_MODEL_393f97101dfa44f0b96c47b9df15999f", "value": 28881.0}}, "82e09efa3f154016ac39adb71d75f2ad": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": ""}}, "8b8b57d6ae544f5b825ac255171f0a28": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": ""}}, "8b91068235b947fdb6735c11f5fa0582": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": ["IPY_MODEL_ef07654480e14fc4ba3a23ef39cec9c3", "IPY_MODEL_c906456413fb472785ba3feb0e0973b6", "IPY_MODEL_5261d8cc2c5e49a3b96499a833231a48"], "layout": "IPY_MODEL_206de8041922434586fe9e6e86eab771"}}, "9ab4e3e009ba45169ea9e90d45f0abbe": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": ""}}, "9d41038f33ea4e92894a6c7e5fa8c975": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "9de2b9ee341d40f6b2cf081465a2e269": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": ""}}, "9e5f9824b2ba42218528b0b0eb72d2b0": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "a3593ed16703434f90a16b53797ff6e8": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "a3a4cf5a544d4366b4983961dfdb3e33": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "a843b546527243cdb4aa022400fbc626": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "ab3cb3da37554d54a6dab4c36d4bf765": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_9e5f9824b2ba42218528b0b0eb72d2b0", "placeholder": "\u200b", "style": "IPY_MODEL_8b8b57d6ae544f5b825ac255171f0a28", "value": ""}}, "ab51db5ce0be46298012e0e4c0c55418": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_1b3f7549a63340148dc5eaf231f795ad", "placeholder": "\u200b", "style": "IPY_MODEL_9de2b9ee341d40f6b2cf081465a2e269", "value": " 29696/? [00:00<00:00, 1518248.27it/s]"}}, "b398f5d2f21745be84095db6cb1c3846": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": ""}}, "b43020d87f714f61998e5d63827c3fa7": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_0be9aa37a2154a4b9f1636e52bd0e7a5", "placeholder": "\u200b", "style": "IPY_MODEL_82e09efa3f154016ac39adb71d75f2ad", "value": " 5120/? [00:00<00:00, 253384.42it/s]"}}, "b6dfd3d280c34161a381f31c5ecb0730": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": ""}}, "c071aa1bfc0a4442a6b87368e704db24": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": ["IPY_MODEL_ab3cb3da37554d54a6dab4c36d4bf765", "IPY_MODEL_06ac5cbee49d441cb827fede0061f716", "IPY_MODEL_f219258ee789434aa5037bae0c0e613e"], "layout": "IPY_MODEL_a3593ed16703434f90a16b53797ff6e8"}}, "c88645ccfa1c48fc81d4c2dcc515b2d6": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HBoxModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HBoxModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HBoxView", "box_style": "", "children": ["IPY_MODEL_2c3e35427a8443d194a39c6a848e1bcd", "IPY_MODEL_27ec4bd412624bb897df9de324e35326", "IPY_MODEL_b43020d87f714f61998e5d63827c3fa7"], "layout": "IPY_MODEL_cc1ac39ffbae4e9aaaf22c51f739d61e"}}, "c906456413fb472785ba3feb0e0973b6": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "FloatProgressModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "FloatProgressModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "ProgressView", "bar_style": "success", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_34802630367846c68da08e9091be15a1", "max": 1.0, "min": 0.0, "orientation": "horizontal", "style": "IPY_MODEL_b398f5d2f21745be84095db6cb1c3846", "value": 1.0}}, "cc1ac39ffbae4e9aaaf22c51f739d61e": {"model_module": "@jupyter-widgets/base", "model_module_version": "1.2.0", "model_name": "LayoutModel", "state": {"_model_module": "@jupyter-widgets/base", "_model_module_version": "1.2.0", "_model_name": "LayoutModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "LayoutView", "align_content": null, "align_items": null, "align_self": null, "border": null, "bottom": null, "display": null, "flex": null, "flex_flow": null, "grid_area": null, "grid_auto_columns": null, "grid_auto_flow": null, "grid_auto_rows": null, "grid_column": null, "grid_gap": null, "grid_row": null, "grid_template_areas": null, "grid_template_columns": null, "grid_template_rows": null, "height": null, "justify_content": null, "justify_items": null, "left": null, "margin": null, "max_height": null, "max_width": null, "min_height": null, "min_width": null, "object_fit": null, "object_position": null, "order": null, "overflow": null, "overflow_x": null, "overflow_y": null, "padding": null, "right": null, "top": null, "visibility": null, "width": null}}, "d0ecfa8069034fb1a59d8f07df5e8ffd": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": ""}}, "da557cc64d5e48f38ab34c38c093da91": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "ProgressStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "ProgressStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "bar_color": null, "description_width": ""}}, "e74acd449f0d481c8bb617604a29bf17": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": ""}}, "ef07654480e14fc4ba3a23ef39cec9c3": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_6c4419068928469b8786215c65fae984", "placeholder": "\u200b", "style": "IPY_MODEL_3f600402fad44322af467d05180651bb", "value": "Epoch 4: 100%"}}, "f219258ee789434aa5037bae0c0e613e": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "HTMLModel", "state": {"_dom_classes": [], "_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "HTMLModel", "_view_count": null, "_view_module": "@jupyter-widgets/controls", "_view_module_version": "1.5.0", "_view_name": "HTMLView", "description": "", "description_tooltip": null, "layout": "IPY_MODEL_31ba14611cff4b04a92fa1288b37c5fb", "placeholder": "\u200b", "style": "IPY_MODEL_ffdd718ba84a4d68a8b38b79ed83ac2d", "value": " 1649664/? [00:00<00:00, 50073761.14it/s]"}}, "ffdd718ba84a4d68a8b38b79ed83ac2d": {"model_module": "@jupyter-widgets/controls", "model_module_version": "1.5.0", "model_name": "DescriptionStyleModel", "state": {"_model_module": "@jupyter-widgets/controls", "_model_module_version": "1.5.0", "_model_name": "DescriptionStyleModel", "_view_count": null, "_view_module": "@jupyter-widgets/base", "_view_module_version": "1.2.0", "_view_name": "StyleView", "description_width": ""}}}, "version_major": 2, "version_minor": 0}}}, "nbformat": 4, "nbformat_minor": 5}