Skip to content

Instantly share code, notes, and snippets.

@jvanvugt
Created November 16, 2018 22:05
Show Gist options
  • Save jvanvugt/107d0703768a88aad586a843447129c6 to your computer and use it in GitHub Desktop.
Save jvanvugt/107d0703768a88aad586a843447129c6 to your computer and use it in GitHub Desktop.
Variational AutoEncoder
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"import math\n",
"\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import torch\n",
"from torch import nn\n",
"import torch.nn.functional as F\n",
"from torchvision import datasets, transforms\n",
"import tqdm"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"PROBA_OUT = False # Output gaussians over pixel values\n",
"SSE_RECON_LOSS = False # only if not PROBA_OUT: use SSE loss, otherwise BCE\n",
"DO_SIGMOID = not(PROBA_OUT or SSE_RECON_LOSS)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"class VAE(nn.Module):\n",
" def __init__(self, z_dim=2, hidden_dim=512, probabilistic_output=False):\n",
" super().__init__()\n",
" self.encoder = nn.Sequential(\n",
" nn.Linear(28*28, hidden_dim),\n",
" nn.ReLU(),\n",
" nn.Linear(hidden_dim, z_dim*2),\n",
" )\n",
" self.decoder = nn.Sequential(\n",
" nn.Linear(z_dim, hidden_dim),\n",
" nn.ReLU(),\n",
" nn.Linear(hidden_dim, (bool(probabilistic_output)+1)*28*28),\n",
" )\n",
" self.z_dim = z_dim\n",
"\n",
" def forward(self, x):\n",
" z_mu_sigma = self.encoder(x).view(x.shape[0], 2, self.z_dim)\n",
" z_mu, z_sigma = z_mu_sigma[:, 0], z_mu_sigma[:, 1]\n",
" z_sigma = torch.exp(z_sigma)\n",
" z_sample = torch.randn(x.shape[0], self.z_dim).cuda()\n",
" z_sample = z_sample * z_sigma + z_mu\n",
" return self.decoder(z_sample), (z_mu, z_sigma)\n",
"\n",
"\n",
"def gaussian_log_prob(x, mu, sigma):\n",
" return torch.log(1 / torch.sqrt(2*math.pi*sigma)) - (x-mu)**2/(2*sigma)\n",
"\n",
"vae = VAE(probabilistic_output=PROBA_OUT).cuda()\n",
"optim = torch.optim.Adam(vae.parameters())\n",
"\n",
"train_loader = torch.utils.data.DataLoader(\n",
" datasets.MNIST('data', train=True, download=True, transform=transforms.ToTensor()),\n",
" batch_size=128, shuffle=True\n",
")"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c65c9d62b2e54fb29247e64071545e78",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"HBox(children=(IntProgress(value=0, max=50), HTML(value='')))"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"epoch 0; last KL=334.67828369140625; last RL=15596.2646484375\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAC7CAYAAAB1qmWGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAEk9JREFUeJzt3V+M1fWZx/HPI3/kr8CAkEGoNkI2VuNKJLixZsU0JK4X1V40qVdusgm9WBNNvCjxBthkE7Np7V5004SNRpp0bWpsF9KL7RKDaM2GiMYUFLsYBPkzDH+F4d8MA89ecNiM/J4vc35zfufM+X3n/UrIzDzzPed8fzMPDz/O95+5uwAA9XfbeHcAAFANCjoAZIKCDgCZoKADQCYo6ACQCQo6AGSCgg4AmaCgA0AmWiroZvakmf3FzL4ws3VVdQoYb+Q26sjGulLUzCZJ+l9JayQdlvShpGfd/bPqugd0HrmNuprcwmNXSfrC3fdLkpn9RtLTkpJJb2bsM4C2cner4GnIbXSdZnK7lbdc7p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mVwbW2UTW6T1/W7ths6XdDvknRoxNeHG7GcLLpxoHDj48Jx7k9LzOweSSsk7VRm11ax3HM7q999rnnd6YIeHXLKNJsuZWazJL0t6UV3Pzfe/ely5HZN5JzXnS7ohyUtHfH1EklHO9yHdus3s15Janw8Ps79GRMzm6LrSf9rd/9dI5zFtbVJ7rmdxe8+97zudEH/UNJyM/u2mU2V9CNJWzvch3bbKum5xufPSdoyjn0ZEzMzSa9J2uvur474Vu2vrY1yz+3a/+4nQl53fGGRmT0l6V8lTZL0urv/c0c7UCEze1PSal3fra1f0npJ/ynpt5K+JekrST9095sHmLqamT0m6X1JuyVda4Rf1vX3G2t9be2US26T1/W7thtYKQoAmWClKABkgoIOAJmgoANAJijoAJAJCjoAZIKCDgCZoKADQCYo6ACQif8DeVeYw6MqWVkAAAAASUVORK5CYII=\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x2933a0a5ef0>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"epoch 10; last KL=334.7369689941406; last RL=13866.205078125\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAC7CAYAAAB1qmWGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAEYFJREFUeJzt3VuMVXWWx/Hf4qYIqHgBpWSQePfBW0oco8ZLa8fxxUtsL4nGMRo63k14aMKD3U688NDaPrRppdVAG9CYeONBZ0aJimNGAdGITnlBZAQpKREVULkUrHngMCn5ry2n6uxzqva/vp+EnFOr1j7nv6nFYtf5//fe5u4CAFTfkP4eAACgHDR0AMgEDR0AMkFDB4BM0NABIBM0dADIBA0dADJBQweATDTU0M3sQjP7xMyWm9n0sgYF9DdqG1VkfT1T1MyGSvpU0gWSVktaLO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o99qu/M9+MNR1y08sMrOLJD0kaaikJ9z93pYOoERm9pSkc7Tzam1rJf1R0guSnpH0T5K+lPQ7d999gmlAM7MzJb0paZmkHbXwDO38vLHS+9ZMudQ2dV29fduFM0UBIBOcKQoAmaChA0AmaOgAkAkaOgBkgoYOAJmgoQNAJmjoAJAJGjoAZOL/ANlywWOHz2B3AAAAAElFTkSuQmCC\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x2932eca9518>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"epoch 20; last KL=342.6477355957031; last RL=13823.6806640625\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAC7CAYAAAB1qmWGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAEydJREFUeJzt3XtsleWWx/Hf4qqCgIAiYrmIZsQYB7XoxDGjk6NGDfGSeMzxH5SMwctoMBojQZNDxkyiRj3zx4wiE42cxKOeiA7mGEeImugYMeIlKlMcELlJ04qoFLQods0fbDIdnvXa3Xbv3b4P309C2q4+u/t529XF2/3czN0FACi/IQPdAQBAbVDQASATFHQAyAQFHQAyQUEHgExQ0AEgExR0AMgEBR0AMtGvgm5ml5rZ52a20cwW1apTwEAjt1FG1teVomY2VNL/SLpY0nZJ70u6zt3/u3bdAxqP3EZZDevHY8+RtNHdN0mSmT0n6UpJhUlvZuwzgLpyd6vBlyG3MehUk9v9eclliqRt3T7eXokBZUduo5T6c4ce/W+R3KWY2QJJC/rxPECjkdsopf4U9O2Smrp9fKKkHYc2cvdlkpZJ/FmK0iC3UUr9ecnlfUmnmNkMMxsh6XeSXq5Nt4ABRW6jlPp8h+7u+83sNkmvSRoq6Sl3X1ezngEDhNxGWfV52mKfnow/S1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9Y+XnlMO11UVmuf20yOtSavQd+jmSNrr7Jnf/SdJzkq5scB9qxt3fkrTrkPCVkpZX3l8u6aqGdqoG3L3V3T+svN8hqUXSFGVwbXWUTW6T1+W7toMaXdCnSNrW7ePtlVhOJh08ULjy9rgB7k+/mNl0SWdKek+ZXVuN5Z7bWf3sc83rRhf06JBTptkMUmY2WtIKSXe4++6B7s8gR26XRM553eiCvl1SU7ePT5S0o8F9qLc2M5ssSZW37QPcnz4xs+E6kPTPuPuLlXAW11Ynued2Fj/73PO60QX9fUmnmNkMMxsh6XeSXm5wH+rtZUnXV96/XtLKAexLn5iZSXpSUou7P9rtU6W/tjrKPbdL/7M/HPK64QuLzOxySf8iaaikp9z9nxvagRoys2clXagDu7W1Sfq9pP+Q9GdJUyVtlfRbdz90gGlQM7PzJb0t6VNJXZXwYh14vbHU11ZPueQ2eV2+azuIlaIAkAlWigJAJijoAJAJCjoAZIKCDgCZoKADQCYo6ACQCQo6AGSCgg4AmfhfkOqtlYoeWRAAAAAASUVORK5CYII=\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x2930ac3c048>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"epoch 30; last KL=326.5901794433594; last RL=13260.6181640625\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAC7CAYAAAB1qmWGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAE7xJREFUeJzt3WuM1eW1x/HfcgSpXKyUgshtqBeEHiMoVdLaBNs0FmNjSaOpL6wnNcUXtrGJTUrqizansfWFtiepx0ZOtVhjbTRtj2hTKyGtVkVFiOLAcBkpyMAoIiqgIg6s84JNMuVZf9gz+zL7/8z3k5CZWbP23s8fnln8Z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g==\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x2930aebe358>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"epoch 40; last KL=340.5096740722656; last RL=14156.3173828125\n"
]
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAC7CAYAAAB1qmWGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAE1JJREFUeJzt3XuMVVWWx/HfsqgCBAQLBBF5BXEcHwEjmpHGqFFaRuOjoy3tHyMT25R/jIkmGpuYaKvJBGJsHZMmHRmhQaO2rdBC+g97DDHiGEXUkFYHHd5SUrzfimjhnj+4mBr2OtSt+z6b7ychVbVY9559qvZdderux7EQggAA+XdKvRsAAKgMCjoAJIKCDgCJoKADQCIo6ACQCAo6ACSCgg4AiaCgA0AiyiroZjbNzL40s7VmNrNSjQLqjb6NPLJSV4qaWZOk/5U0VVK7pJWS7ggh/E/lmgfUHn0bedWrjMdeJmltCGG9JJnZnyTdLCmz05sZ+wygqkIIVoGnoW+j4RTTt8t5y2WEpM1dvm4vxIC8o28jl8q5Qvd+W0RXKWbWJqmtjOMAtUbfRi6VU9DbJY3s8vXZkrYcnxRCmCtprsSfpcgN+jZyqZy3XFZKGm9mY82sRdKvJC2tTLOAuqJvI5dKvkIPIXSa2b2S/iapSdL8EMLnFWsZUCf0beRVydMWSzoYf5aiyio0y6XH6NuotmrPcgEANBAKOgAkgoIOAImgoANAIijoAJAICjoAJIKCDgCJoKADQCIo6ACQCAo6ACSCgg4AiaCgA0AiKOgAkAgKOgAkopw7FgE4CZxySnzd19TU5Ob26dMnivXt27eomCQ1NzdHsZaWlu6a+JPvvvvOjf/www9F537//fdR7PDhw27ukSNHolhnZ6ebW4utyrlC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7Wlw9O2cSLlf17qgt0sa2eXrsyVtqXEbqm2bmQ2XpMLH7XVuT0nMrFlHO/1LIYTFhXAS51YlqfftJH72qffrWhf0lZLGm9lYM2uR9CtJS2vchmpbKmlG4fMZkpbUsS0lMTOTNE/S6hDC013+K/fnVkWp9+3c/+xPhn5d84VFZna9pP+Q1CRpfgjh32vagAoys1ckXaWju7Vtk/RbSW9I+rOkUZK+kvTLEMLxA0wNzcymSHpX0qeSfiyEH9bR9xtzfW7VlErfpl/n79yOYaUoACSClaIAkAgKOgAkgoIOAImgoANAIijoAJAICjoAJIKCDgCJoKADQCL+D2z5pJLIIoFFAAAAAElFTkSuQmCC\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x2930ae24898>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n"
]
}
],
"source": [
"for epoch in tqdm.tqdm_notebook(range(50)):\n",
" for images, _ in train_loader:\n",
" images = images.view(-1, 28*28)\n",
" images = images.cuda()\n",
" predicted_images, (z_mu, z_sigma) = vae(images)\n",
" if PROBA_OUT:\n",
" predicted_images = predicted_images.view(images.shape[0], 2, -1)\n",
" mus, stds = predicted_images[:, 0], torch.exp(predicted_images[:, 1])\n",
" predicted_images = mus\n",
" reconstruction_loss = -torch.sum(gaussian_log_prob(images, mus, stds))\n",
" elif SSE_RECON_LOSS:\n",
" reconstruction_loss = torch.sum((predicted_images - images)**2)\n",
" else:\n",
" reconstruction_loss = F.binary_cross_entropy_with_logits(\n",
" predicted_images,images, reduction=\"sum\")\n",
" kl_loss = -0.5 * torch.sum(torch.sum(1 + torch.log(z_sigma) - z_mu*z_mu - z_sigma, dim=1))\n",
" loss = kl_loss + reconstruction_loss\n",
" loss.backward()\n",
" optim.step()\n",
" vae.zero_grad()\n",
"\n",
" if epoch % 10 == 0:\n",
" print(f\"epoch {epoch}; last KL={kl_loss.item()}; last RL={reconstruction_loss.item()}\")\n",
" images = images.view(images.shape[0], 1, 28, 28)\n",
" if DO_SIGMOID:\n",
" predicted_images = torch.sigmoid(predicted_images)\n",
" predicted_images = predicted_images.view(images.shape[0], 1, 28, 28)\n",
" plt.subplot(121)\n",
" plt.imshow(images[0, 0].cpu().numpy(), cmap=\"gray\")\n",
" plt.subplot(122)\n",
" plt.imshow(predicted_images[0, 0].cpu().detach().numpy(), cmap=\"gray\")\n",
" plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Sampling in latent space"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAAC7CAYAAAB1qmWGAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAEPNJREFUeJzt3XmsVGWax/HfIyAKgkEJS2gYTCturWJEHGNrnMhi8w92ItoCBg2RdotLNDZbbCPBEEdpjT0xAUHAhbYTukeC2wBBaMlIFEUFri0GGEFR4ihLZIdn/qDIXHnfgrq3zqm65+X7SUhVPfXWOc+596mHc89q7i4AQPGdVO8EAADZoKEDQCJo6ACQCBo6ACSChg4AiaChA0AiaOgAkAgaOgAkoqqGbmbXm9k/zexLMxubVVJAvVHbKCJr7pmiZtZK0heSBkraLOkDSbe4+9rs0gNqj9pGUbWu4rP9JX3p7uslycz+ImmopLJFb2ZcZwC5cnfLYDLUNlqcSmq7mk0uPSRtavR6cykGFB21jUKqZg099r9FsJZiZmMkjaliPkCtUdsopGoa+mZJPRu9/oWkb44e5O7TJE2T+LMUhUFto5Cq2eTygaRzzOwsMztZ0u8kzc8mLaCuqG0UUrPX0N39gJndK+kdSa0kzXT3NZllBtQJtY2iavZhi82aGX+WImcZHeXSZNQ28pb3US4AgBaEhg4AiaChA0AiaOgAkAgaOgAkgoYOAImgoQNAImjoA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kv4sqfFt5cdKWuzuU8xsbOn1H7JPrzjKHdES88Ybb+SYyc/t2LEjiC1YsCA6duzYsUHspptuio6dPXt2dYm1DLOUeG2fdFJ8nW369OlBrFOn+P9dsUtVPPPMM9Gx27dvryivm2++ORqPXUKjKS677LKqPl90x11Dd/dlkn44KjxU0pFv9GxJN2ScF5A7ahupae429K7uvkWSSo/hFaCAYqK2UVi5n1hkZmMkjcl7PkCtUdtoaZq7hv6dmXWXpNLj1nID3X2au/dz9/DarEDLQ22jsCx2Wm4wyKy3pAXu/qvS63+X9L+Ndhyd4e7Hva12CndGb9euXTS+evXqINa5c+fo2AsvvDCIbdq0qbrEmqBDhw7ReOySBD/++GN07EUXXRTE9uzZU11iGajkzuiNpVTbsR2gjz32WHTsxIkTK57uxx9/HMRaws7HM888M4iVu3Z627ZtK55ubOz+/fsrTywnldR2JYctzpX035LONbPNZjZa0hRJA81snaSBpddAoVDbSM1xt6G7+y1l3rou41yAmqK2kRrOFAWARNDQASARNHQASAQ3uGii9u3bR+NnnXVWECt35Eotj2iJ2blzZzT+1ltvBbGRI0dGx55yyilBrCUc5XIiO//884NYU45mOXjwYDT+1FNPNTunPD388MNBrClHs7z++uvReLmfQxGwhg4AiaChA0AiaOgAkAgaOgAkgp2iTTRgwICKxy5cuDDHTLK3bdu2eqeACvTp0ycar7benn766Wh87ty5VU23Wr169YrGR40aVdV0ly5dGo3HLo1R6XXe6401dABIBA0dABJBQweARNDQASAR7BQ9htatwx/P6NGjo2MPHDgQxF588cXMc8rT2rVrg9j7778fHVvubFPk79xzz43Gu3XrVvE0Yjcqf/zxx5udU57atGkTjce+n00xderUaHzSpElB7Oqrr46OXbVqVVU5ZI01dABIBA0dABJBQweARNDQASARldxTdKaZbTWz1Y1ij5nZ12a2qvRvSL5pAtmjtpGaSnYTz5L0Z0lzjor/yd1b5oWSMxI7Bfi66+K3m9yyZUsQe++99zLPKU+XXHJJEPvpp5+iY4t8zehGZqmAtT1s2LCqpxE7wmPfvn3Rsbfeem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qf8/m7HZh+7ery4zzxHLdWJL+eeU6rKltFxscgGARNDQASAR9Wzo0+o47zyxXCe2lH9OqS5bMstVt23oAIBssckFABJR84ZuZteb2T/N7EszG1vr+WepdEf4rWa2ulHsDDNbaGbrSo+Fu2O8mfU0syVm1mBma8zs/lK88MuWp1Rqm7ou3rIdUdOGbmatJP2HpN9IukDSLWZ2QS1zyNgsSdcfFRsrabG7nyNpcel10RyQ9JC7ny/pXyXdU/o9pbBsuUistmeJui6kWq+h95f0pbuvd/d9kv4iaWiNc8iMuy+T9MNR4aGSZpeez5Z0Q02TyoC7b3H3j0rPd0pqkNRDCSxbjpKpbeq6eMt2RK0beg9Jmxq93lyKpaTrkRsKlx671DmfqphZb0mXSlqhxJYtY6nXdlK/+1TrutYNPXaTUw6zaaHM7DRJ8yQ94O476p1PC0dtF0TKdV3rhr5ZUs9Gr38h6Zsa55C378ysuySVHrfWOZ9mMbM2Olz0r7j730rhJJYtJ6nXdhK/+9TrutYN/QNJ55jZWWZ2sqTfSZpf4xzyNl/SqNLzUZJer2MuzWJmJmmGpAZ3n9rorcIvW45Sr+3C/+5PhLqu+YlFZjZE0jOSWkma6e6Ta5pAhsxsrqRrdfhqbd9J+qOk/5T0V0m9JH0laZi7H72DqUUzs19L+oekzyQdKoXH6/D2xkIvW55SqW3qunjLdgRnigJAIjhTFAASQUMHgETQ0AEgETR0AEgEDR0AEkFDB4BE0NABIBE0dABIxP8BEUk23tWL+nAAAAAASUVORK5CYII=\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x2933a079080>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
},
{
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAABcCAYAAAB+6068AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAG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9Ra71n8+0VgD3DmiJudabukTQZJm3QzBrukTTqY1A39TGBf6/1+Ru/ka0YpZStwKXDn4kdfKqXcX0r5Zill8wo2NTd2SZsMkjbppie7pE06mNQNvWsl3plMrymlnADsAL5ca30B+HfgfOAS4ADwryvZXMdnM2eXtMkgaZNuerRL2qSDSd3Q9wNnt96fBTw9oX33RinlOBYMf1Ot9WaAWusztdYjtdZXgP9gYSi4XGbeLmmTQdIm3fRsl7RJB5O6od8FbCulnFtK2QR8GvjOhPbdC2VhHapvAHtqrV9vfb6l9bW/AXatYLMzbZe0ySBpk27GYJe0SQcTqbZYaz1cSvkScCsL0elv1lp3T2LfPXIl8HnggVLKvYuffRX4TCnlEhaGe48Df7fcDc6BXdImg6RNuunVLmmTbnKmaJIkyZyQM0WTJEnmhLyhJ0mSzAl5Q0+SJJkT8oaeJEkyJ+QNPUmSZE7IG3qSJMmckDf0JEmSOSFv6EmSJHPC/wPoAQrOW8G6tgAAAABJRU5ErkJggg==\n",
"text/plain": [
"<matplotlib.figure.Figure at 0x2930aefab38>"
]
},
"metadata": {
"needs_background": "light"
},
"output_type": "display_data"
}
],
"source": [
"images = images.view(-1, 28 * 28)\n",
"image_a = images[0].unsqueeze(0)\n",
"image_b = images[1].unsqueeze(0)\n",
"plt.subplot(121)\n",
"plt.imshow(image_a.view(28, 28).cpu().numpy(), cmap=\"gray\")\n",
"plt.subplot(122)\n",
"plt.imshow(image_b.view(28, 28).cpu().numpy(), cmap=\"gray\")\n",
"plt.show()\n",
"z_a = vae(image_a)[1][0]\n",
"z_b = vae(image_b)[1][0]\n",
"\n",
"# linearly interpolate from image_a to image_b (inclusive)\n",
"n_interps = 5\n",
"interps_z = z_a + (z_b - z_a) * torch.linspace(0, 1, n_interps).view(n_interps, 1).cuda()\n",
"interps_images = vae.decoder(interps_z).detach()\n",
"if DO_SIGMOID:\n",
" interps_images = torch.sigmoid(interps_images)\n",
"interps_images = interps_images.view(n_interps, bool(PROBA_OUT)+1, 28, 28)\n",
"_, axs = plt.subplots(1, n_interps)\n",
"for ax, image in zip(axs, interps_images):\n",
" ax.imshow(image[0].cpu().numpy(), cmap=\"gray\")\n",
"plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.6.5"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment