Ege Demir commited on
Commit
acdff3f
1 Parent(s): 056b91b

Initial commit

Browse files
Files changed (1) hide show
  1. NoiseGAN_MNIST.ipynb +1 -0
NoiseGAN_MNIST.ipynb ADDED
@@ -0,0 +1 @@
 
 
1
+ {"cells":[{"cell_type":"code","execution_count":1,"id":"9b898c12-9136-4195-8da9-dfcec6fcc45c","metadata":{"id":"9b898c12-9136-4195-8da9-dfcec6fcc45c","executionInfo":{"status":"ok","timestamp":1652803135917,"user_tz":300,"elapsed":6845,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[],"source":["import glob\n","import imageio\n","import matplotlib.pyplot as plt\n","import numpy as np\n","import os\n","import PIL\n","from tensorflow.keras import layers\n","import time\n","import tensorflow as tf\n","from IPython import display\n","from IPython.display import clear_output\n","#from sklearn.model_selection import train_test_split\n","#from sklearn.utils import shuffle"]},{"cell_type":"markdown","id":"4dc7fcf6-bc9c-4bb2-a687-18f46a859dd0","metadata":{"id":"4dc7fcf6-bc9c-4bb2-a687-18f46a859dd0"},"source":["# Load and prepare dataset"]},{"cell_type":"code","execution_count":2,"id":"33e6bace-643c-4c8f-81a1-d617ec0f8231","metadata":{"id":"33e6bace-643c-4c8f-81a1-d617ec0f8231","executionInfo":{"status":"ok","timestamp":1652803137026,"user_tz":300,"elapsed":1116,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}},"colab":{"base_uri":"https://localhost:8080/"},"outputId":"904e0be2-d34b-496b-a7bb-f74fd29ebfbb"},"outputs":[{"output_type":"stream","name":"stdout","text":["Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz\n","11493376/11490434 [==============================] - 0s 0us/step\n","11501568/11490434 [==============================] - 0s 0us/step\n"]}],"source":["(train_images, train_labels), (_, _) = tf.keras.datasets.mnist.load_data()"]},{"cell_type":"code","source":["#train_images, train_labels = shuffle(train_images, train_labels, random_state=0)\n","train_labels = tf.keras.utils.to_categorical(train_labels, 10)"],"metadata":{"id":"E5aeErtYttJq","executionInfo":{"status":"ok","timestamp":1652803137027,"user_tz":300,"elapsed":6,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"id":"E5aeErtYttJq","execution_count":3,"outputs":[]},{"cell_type":"code","source":["train_images = (train_images - 127.5) / 127.5 # Normalize the images to [-1, 1]"],"metadata":{"id":"PaYRrz0DuAa2","executionInfo":{"status":"ok","timestamp":1652803137958,"user_tz":300,"elapsed":935,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"id":"PaYRrz0DuAa2","execution_count":4,"outputs":[]},{"cell_type":"code","source":["plt.plot()\n","plt.imshow(train_images[10,:, :], cmap='gray')\n","(tf.ones_like(train_labels[10])-train_labels[10])/9"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":335},"id":"nCmNXkFu1DEw","executionInfo":{"status":"ok","timestamp":1652803138474,"user_tz":300,"elapsed":518,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}},"outputId":"8145953f-45bf-47cd-b75b-ef61077a7d0b"},"id":"nCmNXkFu1DEw","execution_count":5,"outputs":[{"output_type":"execute_result","data":{"text/plain":["<tf.Tensor: shape=(10,), dtype=float32, numpy=\n","array([0.11111111, 0.11111111, 0.11111111, 0. , 0.11111111,\n"," 0.11111111, 0.11111111, 0.11111111, 0.11111111, 0.11111111],\n"," dtype=float32)>"]},"metadata":{},"execution_count":5},{"output_type":"display_data","data":{"text/plain":["<Figure size 432x288 with 1 Axes>"],"image/png":"iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAANcElEQVR4nO3df6gd9ZnH8c9ntVE0kSSK8WL9kUZFg2KyRlFWF9eSkhUlFqQ2yOKyws0fVaoI2VDBCJuC7hpXglhIUZtduimFGCql0rghrOs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rftUY8c27pV0tqQtkvZI+k9Jsweot3/X2NDeb2osWEMt9XajxnbR35S0o/i7te3PrqSvvnxuXC4LJMEBOiAJwg4kQdiBJAg7kARhB5Ig7EAShB1I4v8BbAEsnwu8EY8AAAAASUVORK5CYII=\n"},"metadata":{"needs_background":"light"}}]},{"cell_type":"code","execution_count":6,"id":"0e4e11d8-dc5e-459e-b6f6-af0a3d832df5","metadata":{"id":"0e4e11d8-dc5e-459e-b6f6-af0a3d832df5","executionInfo":{"status":"ok","timestamp":1652803140833,"user_tz":300,"elapsed":243,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[],"source":["BUFFER_SIZE = 60000\n","BATCH_SIZE = 256"]},{"cell_type":"code","execution_count":7,"id":"a19856b3-e156-4b71-bca5-c7becc384919","metadata":{"id":"a19856b3-e156-4b71-bca5-c7becc384919","executionInfo":{"status":"ok","timestamp":1652803143977,"user_tz":300,"elapsed":101,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[],"source":["# Batch and shuffle the data\n","dataset = tf.data.Dataset.from_tensor_slices((train_images,train_labels)).shuffle(BUFFER_SIZE).batch(BATCH_SIZE)\n","#train_Output = tf.data.Dataset.from_tensor_slices(train_labels).batch(BATCH_SIZE)"]},{"cell_type":"markdown","id":"e7ccd168-0851-4095-8133-8f2ab00893aa","metadata":{"id":"e7ccd168-0851-4095-8133-8f2ab00893aa"},"source":["# Create Models"]},{"cell_type":"markdown","id":"1767b2ba-1c4b-4468-9862-4f9e2b665b69","metadata":{"id":"1767b2ba-1c4b-4468-9862-4f9e2b665b69"},"source":["### Generator"]},{"cell_type":"code","execution_count":8,"id":"fc6901fb-6955-4ce3-b2bc-e022a1444cc3","metadata":{"id":"fc6901fb-6955-4ce3-b2bc-e022a1444cc3","executionInfo":{"status":"ok","timestamp":1652803148596,"user_tz":300,"elapsed":108,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[],"source":["def make_generator_model():\n"," model = tf.keras.Sequential()\n"," model.add(layers.Dense(7*7*256, use_bias=False, input_shape=(100,)))\n"," model.add(layers.BatchNormalization())\n"," model.add(layers.LeakyReLU())\n","\n"," model.add(layers.Reshape((7, 7, 256)))\n"," assert model.output_shape == (None, 7, 7, 256) # Note: None is the batch size\n","\n"," model.add(layers.Conv2DTranspose(128, (5, 5), strides=(1, 1), padding='same', use_bias=False))\n"," assert model.output_shape == (None, 7, 7, 128)\n"," model.add(layers.BatchNormalization())\n"," model.add(layers.LeakyReLU())\n","\n"," model.add(layers.Conv2DTranspose(64, (5, 5), strides=(2, 2), padding='same', use_bias=False))\n"," assert model.output_shape == (None, 14, 14, 64)\n"," model.add(layers.BatchNormalization())\n"," model.add(layers.LeakyReLU())\n","\n"," model.add(layers.Conv2DTranspose(1, (5, 5), strides=(2, 2), padding='same', use_bias=False, activation='tanh'))\n"," assert model.output_shape == (None, 28, 28, 1)\n","\n"," return model"]},{"cell_type":"code","execution_count":9,"id":"cb7a2cfe-0392-4986-8096-5c9ca350e564","metadata":{"id":"cb7a2cfe-0392-4986-8096-5c9ca350e564","outputId":"bf91f82c-f5fa-471e-be49-f3ee49adc0d6","colab":{"base_uri":"https://localhost:8080/","height":283},"executionInfo":{"status":"ok","timestamp":1652803151323,"user_tz":300,"elapsed":682,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[{"output_type":"execute_result","data":{"text/plain":["<matplotlib.image.AxesImage at 0x7ff5e7c429d0>"]},"metadata":{},"execution_count":9},{"output_type":"display_data","data":{"text/plain":["<Figure size 432x288 with 1 Axes>"],"image/png":"iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAYm0lEQVR4nO2de3CV5bXGn0UMeAkVIlchIDc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R2IRJBZhciEWR2IRIhp6m3Tp06YcCAAUF9+fLlNJ6VesbSdrFySVY2CACf+9znghorvQXia9u+fTvVY2tnbZFjKceXX36Z6ixFBABvvvkm1Vn32ljZcex5jZU119TUBLX33nuPxo4bN47qsbLjUaNGUZ2l14499lgaG0tJhtCRXYhEkNmFSASZXYhEkNmFSASZXYhEkNmFSASZXYhEyGme/cCBAzSfzSalAsDmzZuDWiwX3aNHD6qfffbZVJ83L9xE99xzz6WxrCQRAMrLy6key4X3798/qO3evZvGxlpNs1w1ABx55JFU37ZtW1CLjWSOlYnGylBZGevUqVNp7OzZs6kem347fPhwqh9zzDFBLVbiev755wc1lbgKIWR2IVJBZhciEWR2IRJBZhciEWR2IRJBZhciEXKaZy8qKkJJSUlQj7U9ZrXVRx99NI2N5boffPBBqn/pS18KarF2zLE213PnzqV6rDaa5eFj46Lvueceqt96661U//GPf0z1Cy64IKix9wIQv/bhscceo/pNN90U1J577jka261bN6rHXvPVq+n0cnpNCWsNDvDW42zseVZmN7NNAGoBHATQ4O4js3k8IUT70RZH9vPdPTxZXghREOh/diESIVuzO4DnzGyZmU1r7g5mNs3MKsysItZTTAjRfmT7MX60u1eZWQ8A883sbXdf3PQO7j4TwEwAOOGEE3j1gBCi3cjqyO7uVZnvNQDmAjirLRYlhGh7Wm12MzvGzDofvg3giwBWtdXChBBtSzYf43sCmJvpYX0EgP9z92dYgJmhY8eOrd4hqyGeMGECjX3ppZeoHqvrHjhwYFBjtclAvLd6LN984MABqo8YMSKoLV68OKgBwPTp06keyxfffffdVGc16e+//z6NZTljALj//vupvmbNmqDGeu0DfE4AAKxdu5bqsTw964GwYsUKGstmATCPtNrs7l4J4IzWxgshcotSb0IkgswuRCLI7EIkgswuRCLI7EIkQk5LXOvr6+l44lhbYpZK2bdvH42NPfaePXuoXllZGdRi5Y6x1Fus7TD7vQHg4osvDmqxUdQvvvgi1WOlw7FSUZYK6tSpE42Npd6WLl1Kdfa7DxkyhMZWV1dTPVa2HEunfvjhh0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LI7EIkgswuRCLI7EIkQk5bSRcXF9PWxrERviwdEisLzHZk87p164IaG+cMAOXl5VSfMGEC1WMpKlZuGUudsTbUAPDoo49S/eKLL6b6K6+8EtSuv/56GsvaIgPA3r17qd65c+eg9oUv8GTS888/T/XXX3+d6rHyXfaasVJugI8AZ+9zHdmFSASZXYhEkNmFSASZXYhEkNmFSASZXYhEkNmFSISc5tkPHTpES/A6depE41lsrIQ1lkd/9tlnqc7yyWyELhBvt8zKHYF4nv7BBx8MarHRw08+yVsRxFomx9b+la98JajF2lS/8MILVB84cCDVt23bFtRir3es9Dc2pvuOO+6g+sKFC4Na7Hlh1xcwj+jILkQiyOxCJILMLkQiyOxCJILMLkQiyOxCJILMLkQi5HRkc9++fZ21RR4+fDiNf/fdd4Na7Pf48MMPqR6rST/nnHOozqisrKT6gAEDqD548GCqs7bILJ8LANOmTaN67HlhtdUAz8PHXm+WMwaAE088keozZ84MarHrD/bt20f1WJvrr3/961RntfzLly+nsazV9DXXXIO1a9e2bmSzEOLfA5ldiESQ2YVIBJldiESQ2YVIBJldiESQ2YVIhJzWs5sZOnQI/33561//SuO7desW1GI52VNOOYXqsVp6liu/9NJLaWysPvkvf/kL1aurq6leV1cX1H7yk5/Q2B/96EdUHzFiBNVjazvttNOC2sMPP0xjY73djz/+eKqzPgBXXXUVjV26dCnVv//971M91hOfzTkYNmwYjd25c2dQa2hoCGrRI7uZPWRmNWa2qsm2O82sysyWZ74mxh5HCJFfWvIx/mEAFzSz/R53L8988bEiQoi8EzW7uy8GwOfRCCEKnmxO0N1gZisyH/O7hu5kZtPMrMLMKmLXGwsh2o/Wmv0BAIMAlAOoBvDz0B3dfaa7j3T3kSUlJa3cnRAiW1pldnff7u4H3f0QgF8DOKttlyWEaGtaZXYz693kx8kAVoXuK4QoDKJ5djObDWAsgG5mthXADwGMNbNyAA5gEwCeVMxQVFSE4447LqjHasZZXnbIkCE0dv369VTv378/1VleNDZPO8aoUaOyit+4cWNQu/nmm2lsrO46VovPZqADvD/7TTfdRGNjs+V37NhB9d27dwe1++67j8b+6le/ovrQoUOpvn//fqp/5jOfCWps3QDotSoszx41u7tf2czm38TihBCFhS6XFSIRZHYhEkFmFyIRZHYhEkFmFyIRclri6u60HHPFihU0fvTo0UEt1iq6rKyM6ps3b6Z6r169ghpr5QwAXbp0ofratWupHksr1tfXB7VYqWWsbXFs348//jjVr7vuuqDWsWNHGvvMM89QffLkyVRnY7YXL15MY4866iiqZ3vp97p164LapEmTaOzKlSuDGvOXjuxCJILMLkQiyOxCJILMLkQiyOxCJILMLkQiyOxCJEJORzb369fPWcllbC0s95lNqWVL4seNGxfUYuN7Y62ie/ToQfVYySMrG160aBGN7d69O9U/+9nPUj3G+++/H9Q+//nP09iamhqqs9cEAO6+++6gFmuBXVRURPUpU6ZQfc6cOVRnJbK1tbU09swzzwxqV199tUY2C5E6MrsQiSCzC5EIMrsQiSCzC5EIMrsQiSCzC5EIOa1nLyoqQteuwUlReOWVV2j8WWeFZ1G8+OKLNDaWL16yZAnVWb54w4YNNJblwQHgZz/7GdXvvfdeqj/99NNBbcyYMTT2t7/9LdWLi4upzl5PANiyZUtQi409ZnlyAHjggQeozn7373znOzR2+vTpVI/Vw8dGiC9YsCCoxUZVs9eMtTXXkV2IRJDZhUgEmV2IRJDZhUgEmV2IRJDZhUgEmV2IRMhpPXv//v399ttvD+qs/zkALFu2LKixGl8g3hc+lgt/5513gtqMGTNo7A033ED18ePHU/21116jenl5eVAza7a0ucUsXbqU6l/96lep/sknnwS1Sy65hMb+8pe/pHrsNWfvl9NPP53GPvroo1SfOnUq1WM16WzWwIABA2jstm3bgtoPfvADVFZWtq6e3czKzGyhma0xs9VmNj2zvdTM5pvZ+sx3fnWFECKvtORjfAOAm919KIBzAHzbzIYCuA3AAncfAmBB5mchRIESNbu7V7v7m5nbtQDWAugDYBKAWZm7zQJwaXstUgiRPf/SCTozOwHAcACvAejp7ocbeW0D0DMQM83MKsysItv5WEKI1tNis5tZCYDHAdzo7nubat54lq/ZM33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2/4LwC53n5H5Q9nV3f+zQNZ2J4B9+R7jnZlW1LvpmHEAlwL4D+TxuSPruhw5eN7ycWQ/C8AGd6909zoAcwBMysM6Ch53Xwxg16c2TwIwK3N7FhrfLDknsLaCwN2r3f3NzO1aAIfHjOf1uSPrygn5MHsfAFua/LwVhTXv3QE8Z2bLzGxavhfTDD3dvTpzexuAnvlcTDNEx3jnkk+NGS+Y564148+zRSfo/pnR7j4CwIUAvp35uFqQeOP/YIWUO23RGO9c0cyY8b+Tz+eutePPsyUfZq8C0HQSYt/MtoLA3asy32sAzEXhjaLefniCbuZ7TZ7X83cKaYx3c2PGUQDPXT7Hn+fD7G8AGGJmA8ysI4ArADyVh3X8E2Z2TObECczsGABfROGNon4KwNWZ21cDeDKPa/kHCmWMd2jMOPL83OV9/Lm75/wLwEQ0npHfCOCOfKwhsK6BAN7KfK3O99oAzEbjx7p6NJ7b+AaA4wAsALAewPMASgtobY8CWAlgBRqN1TtPaxuNxo/oKwAsz3xNzPdzR9aVk+dNl8sKkQg6QSdEIsjsQiSCzC5EIsjsQiSCzC5EIsjsQiSCzC5EIvw/uA194DHc+T0AAAAASUVORK5CYII=\n"},"metadata":{"needs_background":"light"}}],"source":["generator = make_generator_model()\n","\n","noise = tf.random.normal([1, 100])\n","generated_image = generator(noise, training=False)\n","\n","plt.imshow(generated_image[0, :, :, 0], cmap='gray')"]},{"cell_type":"code","execution_count":10,"id":"0757d848-35f2-43fe-9bcf-0783eb9961eb","metadata":{"jupyter":{"source_hidden":true},"tags":[],"id":"0757d848-35f2-43fe-9bcf-0783eb9961eb","outputId":"7fb36185-db08-4404-9482-3c0ca3f7229f","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1652803158040,"user_tz":300,"elapsed":270,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[{"output_type":"execute_result","data":{"text/plain":["TensorShape([1, 100])"]},"metadata":{},"execution_count":10}],"source":["noise.shape"]},{"cell_type":"markdown","id":"d9ccb4d2-c3bf-449c-81b8-67be386faba2","metadata":{"id":"d9ccb4d2-c3bf-449c-81b8-67be386faba2"},"source":["### Discriminator"]},{"cell_type":"code","execution_count":11,"id":"aa937314-8706-4683-bc3b-2af54cbb07ff","metadata":{"id":"aa937314-8706-4683-bc3b-2af54cbb07ff","executionInfo":{"status":"ok","timestamp":1652803163226,"user_tz":300,"elapsed":94,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[],"source":["def make_discriminator_model():\n"," model = tf.keras.Sequential()\n"," model.add(layers.Conv2D(64, (5, 5), strides=(2, 2), padding='same',\n"," input_shape=[28, 28, 1]))\n"," model.add(layers.LeakyReLU())\n"," model.add(layers.Dropout(0.3))\n","\n"," model.add(layers.Conv2D(128, (5, 5), strides=(2, 2), padding='same'))\n"," model.add(layers.LeakyReLU())\n"," model.add(layers.Dropout(0.3))\n","\n"," model.add(layers.Flatten())\n"," model.add(layers.Dense(10))\n","\n"," return model"]},{"cell_type":"code","execution_count":12,"id":"b59749ff-cb51-42e7-8bf5-2aadd385dd08","metadata":{"id":"b59749ff-cb51-42e7-8bf5-2aadd385dd08","outputId":"bc1c7a41-b7a1-48da-8646-2303d01ff218","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1652803170205,"user_tz":300,"elapsed":166,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[{"output_type":"stream","name":"stdout","text":["[[-0.00056131 -0.00143596 -0.00044726 0.00029216 0.00259938 0.00253208\n"," 0.00081216 0.00247406 -0.00045293 -0.00040228]]\n"]}],"source":["discriminator = make_discriminator_model()\n","decision = discriminator(generated_image)\n","print (decision.numpy())"]},{"cell_type":"markdown","id":"61f99800-9e43-455b-9685-d1e606e9be1b","metadata":{"id":"61f99800-9e43-455b-9685-d1e606e9be1b"},"source":["# Define Loss and Optimizers"]},{"cell_type":"code","execution_count":13,"id":"68a2fcc5-7dc7-47f5-9ba7-e3d01ec0320f","metadata":{"id":"68a2fcc5-7dc7-47f5-9ba7-e3d01ec0320f","executionInfo":{"status":"ok","timestamp":1652803174068,"user_tz":300,"elapsed":114,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[],"source":["# This method returns a helper function to compute cross entropy loss\n","cross_entropy_categorical = tf.keras.losses.CategoricalCrossentropy(from_logits=True)\n","cross_entropy_binary = tf.keras.losses.BinaryCrossentropy(from_logits=True)\n"]},{"cell_type":"code","execution_count":14,"id":"c8a1a33a-4922-4caa-9e0f-6a97b572b231","metadata":{"id":"c8a1a33a-4922-4caa-9e0f-6a97b572b231","executionInfo":{"status":"ok","timestamp":1652803175660,"user_tz":300,"elapsed":103,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[],"source":["def discriminator_loss(y_pred,y_real):\n"," return cross_entropy_categorical(y_real,y_pred)"]},{"cell_type":"code","execution_count":15,"id":"d7491e96-92b4-4097-91af-0eac8c9babf2","metadata":{"id":"d7491e96-92b4-4097-91af-0eac8c9babf2","executionInfo":{"status":"ok","timestamp":1652803185394,"user_tz":300,"elapsed":83,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[],"source":["def generator_loss(y_pred,y_real):\n"," return cross_entropy_categorical((tf.ones_like(y_real)-y_real),y_pred) #Add regularizer\n"]},{"cell_type":"code","source":["def disc_evaluate(x,y):\n","\n"," predictions = np.argmax(discriminator(x).numpy(),axis=1).shape\n"," print(np.count_nonzero(np.argmax(y,axis=1)-predictions))\n"," return 0"],"metadata":{"id":"IHYgi0q8fZw-","executionInfo":{"status":"ok","timestamp":1652803216890,"user_tz":300,"elapsed":86,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"id":"IHYgi0q8fZw-","execution_count":16,"outputs":[]},{"cell_type":"code","execution_count":17,"id":"5435e5a5-a891-43b2-8041-d4c14a9ef8ff","metadata":{"id":"5435e5a5-a891-43b2-8041-d4c14a9ef8ff","executionInfo":{"status":"ok","timestamp":1652803218211,"user_tz":300,"elapsed":92,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[],"source":["generator_optimizer = tf.keras.optimizers.Adam(1e-4)\n","discriminator_optimizer = tf.keras.optimizers.Adam(1e-4)\n"]},{"cell_type":"code","execution_count":18,"id":"5e99dc41-2a9d-46b0-ac7c-1bb05ddfee44","metadata":{"id":"5e99dc41-2a9d-46b0-ac7c-1bb05ddfee44","executionInfo":{"status":"ok","timestamp":1652803218969,"user_tz":300,"elapsed":126,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[],"source":["checkpoint_dir = './training_checkpoints'\n","checkpoint_prefix = os.path.join(checkpoint_dir, \"ckpt\")\n","checkpoint = tf.train.Checkpoint(generator_optimizer=generator_optimizer,\n"," discriminator_optimizer=discriminator_optimizer,\n"," generator=generator,\n"," discriminator=discriminator)\n"]},{"cell_type":"markdown","id":"2eaaed33-0ff9-49db-a25b-287d749fc7b2","metadata":{"id":"2eaaed33-0ff9-49db-a25b-287d749fc7b2"},"source":["# Define training loop"]},{"cell_type":"code","execution_count":19,"id":"8ccd0a2a-ac70-4cd7-a166-43352d3bf9c5","metadata":{"id":"8ccd0a2a-ac70-4cd7-a166-43352d3bf9c5","executionInfo":{"status":"ok","timestamp":1652803240064,"user_tz":300,"elapsed":98,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[],"source":["EPOCHS = 500\n","noise_dim = 100\n","num_examples_to_generate = 16\n","\n","# You will reuse this seed overtime (so it's easier)\n","# to visualize progress in the animated GIF)\n","seed = tf.random.normal([num_examples_to_generate, noise_dim])\n"]},{"cell_type":"code","execution_count":20,"id":"166f6307-525a-46f3-9cf9-448900600dc6","metadata":{"id":"166f6307-525a-46f3-9cf9-448900600dc6","executionInfo":{"status":"ok","timestamp":1652803243129,"user_tz":300,"elapsed":87,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[],"source":["# Notice the use of `tf.function`\n","# This annotation causes the function to be \"compiled\".\n","@tf.function\n","def train_step(train_X,train_Y):\n"," train_X = tf.cast(train_X, tf.float32)\n"," rand_in = tf.random.normal([BATCH_SIZE, noise_dim])\n","\n"," with tf.GradientTape() as gen_tape, tf.GradientTape() as disc_tape:\n"," \n"," generated_noise = generator(rand_in, training=True)\n"," generated_noise = tf.squeeze(generated_noise)\n","\n"," \n"," \n"," disc_output = discriminator(generated_noise+train_X, training=True)\n","\n"," gen_loss = generator_loss(disc_output,train_Y)\n"," disc_loss = discriminator_loss(disc_output, train_Y)\n","\n"," gradients_of_generator = gen_tape.gradient(gen_loss, generator.trainable_variables)\n"," gradients_of_discriminator = disc_tape.gradient(disc_loss, discriminator.trainable_variables)\n","\n"," generator_optimizer.apply_gradients(zip(gradients_of_generator, generator.trainable_variables))\n"," discriminator_optimizer.apply_gradients(zip(gradients_of_discriminator, discriminator.trainable_variables))\n","\n"," return gen_loss,disc_loss\n"]},{"cell_type":"code","execution_count":21,"id":"db65c45a-8d89-4116-8e8b-7cc613f98ce9","metadata":{"id":"db65c45a-8d89-4116-8e8b-7cc613f98ce9","executionInfo":{"status":"ok","timestamp":1652803245493,"user_tz":300,"elapsed":3,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[],"source":["def train(dataset, epochs):\n"," for epoch in range(epochs):\n"," print(\"epoch: \"+ str(epoch))\n"," gen_loss_sum = 0\n"," disc_loss_sum = 0\n","\n"," start = time.time()\n","\n"," for x,y in dataset:\n"," gen_loss,disc_loss = train_step(x,y)\n","\n"," gen_loss_sum = gen_loss_sum + gen_loss\n"," disc_loss_sum = disc_loss_sum + disc_loss\n","\n"," clear_output()\n"," print(disc_evaluate(x,y))\n"," print(\"Generator Loss: \"+ str(gen_loss.numpy()))\n"," print(\"Discriminator Loss: \"+ str(disc_loss.numpy()))\n","\n"," generate_and_save_images(generator,seed)\n","\n"," generated_image = generator(seed, training=False)\n"," plt.imshow(generated_image[0, :, :, 0], cmap='gray')\n"," plt.show()\n"," \n","\n"," print(\"Generator Epoch Loss: \"+ str(gen_loss_sum))\n"," print(\"Discriminator Epoch Loss: \"+ str(disc_loss_sum))\n"," print(\"-----------------------------------\")\n","\n"," # Produce images for the GIF as you go\n"," display.clear_output(wait=True)\n"," #generate_and_save_images(generator,epoch + 1,seed)\n","\n"," # Save the model every 15 epochs\n"," #if (epoch + 1) % 15 == 0:\n"," #checkpoint.save(file_prefix = checkpoint_prefix)\n","\n"," print ('Time for epoch {} is {} sec'.format(epoch + 1, time.time()-start))\n","\n"," # Generate after the final epoch\n"," #display.clear_output(wait=True)\n"," generate_and_save_images(generator,seed)\n"]},{"cell_type":"code","execution_count":null,"id":"dc4629ce-5438-46ff-9ba8-f498807a62d3","metadata":{"id":"dc4629ce-5438-46ff-9ba8-f498807a62d3"},"outputs":[],"source":["def generate_and_save_images(model, test_input):\n"," # Notice `training` is set to False.\n"," # This is so all layers run in inference mode (batchnorm).\n"," predictions = model(test_input, training=False)\n","\n"," fig = plt.figure(figsize=(4, 4))\n","\n"," for i in range(predictions.shape[0]):\n"," plt.subplot(4, 4, i+1)\n"," plt.imshow(predictions[i, :, :, 0] * 127.5 + 127.5, cmap='gray')\n"," plt.axis('off')\n","\n"," plt.show()\n"]},{"cell_type":"markdown","id":"cb2b8616-3f89-4d9a-8cf3-352b221f732f","metadata":{"tags":[],"id":"cb2b8616-3f89-4d9a-8cf3-352b221f732f"},"source":["# Train"]},{"cell_type":"code","execution_count":null,"id":"d5d9b66b-aa37-4076-9d2f-83df4718fed5","metadata":{"id":"d5d9b66b-aa37-4076-9d2f-83df4718fed5","outputId":"56bf500b-96d0-4121-8f49-eedfc306f93f","colab":{"base_uri":"https://localhost:8080/","height":331},"executionInfo":{"status":"error","timestamp":1652765923115,"user_tz":300,"elapsed":2982,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}}},"outputs":[{"output_type":"stream","name":"stdout","text":["epoch: 0\n"]},{"output_type":"error","ename":"KeyboardInterrupt","evalue":"ignored","traceback":["\u001b[0;31m---------------------------------------------------------------------------\u001b[0m","\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)","\u001b[0;32m<ipython-input-47-178de3cf74ec>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mtrain\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdataset\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mEPOCHS\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m","\u001b[0;32m<ipython-input-29-7f9486b74c76>\u001b[0m in \u001b[0;36mtrain\u001b[0;34m(dataset, epochs)\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0my\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mdataset\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m \u001b[0mgen_loss\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mdisc_loss\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtrain_step\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0my\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 11\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0mgen_loss_sum\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mgen_loss_sum\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mgen_loss\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/util/traceback_utils.py\u001b[0m in \u001b[0;36merror_handler\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 148\u001b[0m \u001b[0mfiltered_tb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 149\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 150\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 151\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 152\u001b[0m \u001b[0mfiltered_tb\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0m_process_traceback_frames\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0me\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__traceback__\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/def_function.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args, **kwds)\u001b[0m\n\u001b[1;32m 913\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 914\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mOptionalXlaContext\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_jit_compile\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 915\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_call\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 916\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 917\u001b[0m \u001b[0mnew_tracing_count\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexperimental_get_tracing_count\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/def_function.py\u001b[0m in \u001b[0;36m_call\u001b[0;34m(self, *args, **kwds)\u001b[0m\n\u001b[1;32m 945\u001b[0m \u001b[0;31m# In this case we have created variables on the first call, so we run the\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 946\u001b[0m \u001b[0;31m# defunned version which is guaranteed to never create variables.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 947\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_stateless_fn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;31m# pylint: disable=not-callable\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 948\u001b[0m \u001b[0;32melif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_stateful_fn\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 949\u001b[0m \u001b[0;31m# Release the lock early so that multiple threads can perform the call\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 2955\u001b[0m filtered_flat_args) = self._maybe_define_function(args, kwargs)\n\u001b[1;32m 2956\u001b[0m return graph_function._call_flat(\n\u001b[0;32m-> 2957\u001b[0;31m filtered_flat_args, captured_inputs=graph_function.captured_inputs) # pylint: disable=protected-access\n\u001b[0m\u001b[1;32m 2958\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2959\u001b[0m \u001b[0;34m@\u001b[0m\u001b[0mproperty\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_call_flat\u001b[0;34m(self, args, captured_inputs, cancellation_manager)\u001b[0m\n\u001b[1;32m 1852\u001b[0m \u001b[0;31m# No tape is watching; skip to running the function.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1853\u001b[0m return self._build_call_outputs(self._inference_function.call(\n\u001b[0;32m-> 1854\u001b[0;31m ctx, args, cancellation_manager=cancellation_manager))\n\u001b[0m\u001b[1;32m 1855\u001b[0m forward_backward = self._select_forward_and_backward_functions(\n\u001b[1;32m 1856\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36mcall\u001b[0;34m(self, ctx, args, cancellation_manager)\u001b[0m\n\u001b[1;32m 502\u001b[0m \u001b[0minputs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 503\u001b[0m \u001b[0mattrs\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mattrs\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 504\u001b[0;31m ctx=ctx)\n\u001b[0m\u001b[1;32m 505\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 506\u001b[0m outputs = execute.execute_with_cancellation(\n","\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/execute.py\u001b[0m in \u001b[0;36mquick_execute\u001b[0;34m(op_name, num_outputs, inputs, attrs, ctx, name)\u001b[0m\n\u001b[1;32m 53\u001b[0m \u001b[0mctx\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mensure_initialized\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 54\u001b[0m tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,\n\u001b[0;32m---> 55\u001b[0;31m inputs, attrs, num_outputs)\n\u001b[0m\u001b[1;32m 56\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mcore\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_NotOkStatusException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 57\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mname\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n","\u001b[0;31mKeyboardInterrupt\u001b[0m: "]}],"source":["train(dataset, EPOCHS)"]},{"cell_type":"code","execution_count":null,"id":"744fce29-db0a-428f-9529-2a93f0091b82","metadata":{"id":"744fce29-db0a-428f-9529-2a93f0091b82"},"outputs":[],"source":["checkpoint.restore(tf.train.latest_checkpoint(checkpoint_dir))"]},{"cell_type":"code","execution_count":null,"id":"328c31a3-6a25-4757-ba85-3d9dc5dbd5c2","metadata":{"id":"328c31a3-6a25-4757-ba85-3d9dc5dbd5c2","colab":{"base_uri":"https://localhost:8080/"},"executionInfo":{"status":"ok","timestamp":1652759804241,"user_tz":300,"elapsed":307,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}},"outputId":"a0e32895-795a-4dd3-dd44-327eb333df45"},"outputs":[{"output_type":"stream","name":"stdout","text":["<class 'tensorflow.python.data.ops.dataset_ops.BatchDataset'>\n"]}],"source":["print(type(train_Input))"]},{"cell_type":"code","source":["generated_image = generator(seed, training=False)\n","\n","plt.imshow(generated_image[0, :, :, 0], cmap='gray')"],"metadata":{"colab":{"base_uri":"https://localhost:8080/","height":283},"id":"818GY4-OKTXr","executionInfo":{"status":"ok","timestamp":1652763906335,"user_tz":300,"elapsed":633,"user":{"displayName":"Ege Demir","userId":"03259742218385023481"}},"outputId":"706c2d2f-77d4-472b-bd44-7e1f28d11011"},"id":"818GY4-OKTXr","execution_count":null,"outputs":[{"output_type":"execute_result","data":{"text/plain":["<matplotlib.image.AxesImage at 0x7f67b50dead0>"]},"metadata":{},"execution_count":84},{"output_type":"display_data","data":{"text/plain":["<Figure size 432x288 with 1 Axes>"],"image/png":"iVBORw0KGgoAAAANSUhEUgAAAPsAAAD4CAYAAAAq5pAIAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAUKElEQVR4nO3dfWyVVbYG8GdRKl8FaSmUio0VBBGNF8Zi1NERHW6FYkAUyPDHyI0gE9Q4k0gUvcbPXCQ3V+eOiTFhRhxG5zoaHQUjGLwVQ8YYtCIiqAhUBKF8Q6F8CKXr/tGDt6N91yrnPec9R/bzS0jLebp7NoezOOWsd+8tqgoiOvN1yvUEiCgZLHaiQLDYiQLBYicKBIudKBCdk7yzoqIiLSkpicx79+5tjm9sbIzMevXqZY49fPiwmXvjjx8/Hpl16dLFHNvQ0GDmffv2NfNjx46Zeffu3SOzLVu2mGOLi4vN3PpzA8DZZ59t5tu3b4/MKioqzLEHDx40c+/5Yt13//79zbFHjx418549e5q593fep0+fyOzkyZPmWCvfuXMnGhsbpb0sVrGLyBgAfwBQAOBPqjrP+vqSkhLce++9kfn48ePN+1u6dGlkNnr0aHPsBx98YOY1NTVmvnnz5sjs/PPPN8c+8cQTZn777beb+fr168185Mi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i/ESL/Ud3LlKnqlU5m4AhX+eWr/MCOLd0JTU3/hhPFAgWO1Egcl3s0RfK516+zi1f5wVwbulKZG45/T87ESUn16/sRJQQFjtRIHJS7CIyRkTWi8hGEZmTizlEEZHNIvKZiKwWkbocz2WBiOwSkbVtbisRkXdEZEPqo72QP9m5PSIi21KP3WoRqcnR3CpEZLmIfC4i60Tkt6nbc/rYGfNK5HFL/P/sIlIA4CsA/wrgWwAfAZiqqp8nOpEIIrIZQJWq5vwCDBH5BYAmAH9R1UtSt/0ngH2qOi/1D2Wxqt6XJ3N7BEBTro/xTp1WVN72mHEANwH4N+TwsTPmNQUJPG65eGW/HMBGVa1X1eMA/gZgQg7mkfdUdQWAfT+4eQKAhanPF6L1yZK4iLnlBVVtUNVVqc8PATh1zHhOHztjXonIRbEPAND2LKVvkV/nvSuAZSLysYjYZ0blRpmqnjo7aAeAslxOph3uMd5J+sEx43nz2KVz/HlcfIPux65W1Z8BGAvgztSPq3lJW/8Plk+90w4d452Udo4Z/14uH7t0jz+PKxfFvg1ARZvfn5u6LS+o6rbUx10AXkf+HUW989QJuqmPu3I8n+/l0zHe7R0zjjx47HJ5/Hkuiv0jAINF5HwROQvArwAszsE8fkREeqTeOIGI9ABQjfw7inoxgFPHl04DYB8nmqB8OcY76phx5Pixy/nx56qa+C8ANWh9R34TgH/PxRwi5jUQwKepX+tyPTcAL6H1x7oTaH1vYzqAPgBqAWwA8L8ASvJobi8A+AzAGrQWVnmO5nY1Wn9EXwNgdepXTa4fO2NeiTxuvFyWKBB8g44oECx2okCw2IkCwWInCgSLnSgQLHaiQLDYiQLxf2E5gWptoTpYAAAAAElFTkSuQmCC\n"},"metadata":{"needs_background":"light"}}]},{"cell_type":"code","source":[""],"metadata":{"id":"htU7qPjqUqJ3"},"id":"htU7qPjqUqJ3","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3 (ipykernel)","language":"python","name":"python3"},"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.10"},"colab":{"name":"NoiseGAN.ipynb","provenance":[{"file_id":"https://github.com/egesko/SideChannel-AdversarialAI/blob/main/Tensorflow/GAN/NoiseGAN.ipynb","timestamp":1652752226356}],"collapsed_sections":[]}},"nbformat":4,"nbformat_minor":5}