Kernel: Python 3
#MLP MNIST AE
Installation and imports
In [ ]:
/content/scripts
In [ ]:
In [ ]:
In [ ]:
In [ ]:
Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz
Downloading http://yann.lecun.com/exdb/mnist/train-images-idx3-ubyte.gz to ./MNIST/raw/train-images-idx3-ubyte.gz
HBox(children=(FloatProgress(value=0.0, max=9912422.0), HTML(value='')))
Extracting ./MNIST/raw/train-images-idx3-ubyte.gz to ./MNIST/raw
Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz
Downloading http://yann.lecun.com/exdb/mnist/train-labels-idx1-ubyte.gz to ./MNIST/raw/train-labels-idx1-ubyte.gz
HBox(children=(FloatProgress(value=0.0, max=28881.0), HTML(value='')))
Extracting ./MNIST/raw/train-labels-idx1-ubyte.gz to ./MNIST/raw
Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz
Downloading http://yann.lecun.com/exdb/mnist/t10k-images-idx3-ubyte.gz to ./MNIST/raw/t10k-images-idx3-ubyte.gz
HBox(children=(FloatProgress(value=0.0, max=1648877.0), HTML(value='')))
Extracting ./MNIST/raw/t10k-images-idx3-ubyte.gz to ./MNIST/raw
Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz
Downloading http://yann.lecun.com/exdb/mnist/t10k-labels-idx1-ubyte.gz to ./MNIST/raw/t10k-labels-idx1-ubyte.gz
HBox(children=(FloatProgress(value=0.0, max=4542.0), HTML(value='')))
Extracting ./MNIST/raw/t10k-labels-idx1-ubyte.gz to ./MNIST/raw
/usr/local/lib/python3.7/dist-packages/torchvision/datasets/mnist.py:498: 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:180.)
return torch.from_numpy(parsed.astype(m[2], copy=False)).view(*s)
Basic MLP AE Module
In [ ]:
BasicAEModule(
(vae): AE(
(encoder): Sequential(
(0): Linear(in_features=784, out_features=512, bias=True)
(1): ReLU()
)
(fc_mu): Linear(in_features=512, out_features=20, bias=True)
(decoder): Sequential(
(0): Linear(in_features=20, out_features=512, bias=True)
(1): ReLU()
(2): Linear(in_features=512, out_features=784, bias=True)
(3): Sigmoid()
)
)
)
In [ ]:
BasicAEModule(
(vae): AE(
(encoder): Sequential(
(0): Linear(in_features=784, out_features=512, bias=True)
(1): ReLU()
)
(fc_mu): Linear(in_features=512, out_features=2, bias=True)
(decoder): Sequential(
(0): Linear(in_features=2, out_features=512, bias=True)
(1): ReLU()
(2): Linear(in_features=512, out_features=784, bias=True)
(3): Sigmoid()
)
)
)
Reconstruction
MLP-AE with latent dim 20
In [ ]:
In [ ]:
torch.Size([16, 1, 28, 28])
MLP-AE with latent dim 2
In [ ]:
In [ ]:
torch.Size([16, 1, 28, 28])
Sampling
Random samples from truncated normal distribution
We sample form a truncated normal distribution with a threshold = 5
MLP-AE with latent dim 20
In [ ]:
<matplotlib.image.AxesImage at 0x7ff001966090>
MLP-AE with latent dim 2
In [ ]:
<matplotlib.image.AxesImage at 0x7ff0018bba90>
Grid Sampling
MLP-AE with latent dim 20
In [ ]:
<matplotlib.image.AxesImage at 0x7ff00133e4d0>
MLP-AE with latent dim 2
In [ ]:
<matplotlib.image.AxesImage at 0x7ff0012bc410>
2D Latent Embeddings For MNIST
MLP-AE with latent dim 20
In [ ]:
In [ ]:
MLP-AE with latent dim 2
In [ ]:
In [ ]:
Interpolation
Spherical Interpolation
MLP-AE with latent dim 20
In [ ]:
<matplotlib.image.AxesImage at 0x7ff0011ef110>
MLP-AE with latent dim 2
In [ ]:
<matplotlib.image.AxesImage at 0x7ff0017def90>
Linear Interpolation
MLP-AE with latent dim 20
In [ ]:
<matplotlib.image.AxesImage at 0x7ff001043b50>
MLP-AE with latent dim 2
In [ ]:
<matplotlib.image.AxesImage at 0x7ff001374290>
In [ ]: