Run the following steps to implement a VAE with PyTorch:
- In this recipe, we will use the Fashion MNIST images as input. In order to download the training and test images and load these images, along with the ground-truth labels, to memory, the following functions need to be defined:
def download(filename, source='http://fashion-mnist.s3-website.eu-central-1.amazonaws.com/'): print("Downloading %s" % filename) urlretrieve(source + filename, filename)def load_fashion_mnist_images(filename): if not os.path.exists(filename): download(filename) with gzip.open(filename, 'rb') as f: data = np.frombuffer(f.read(), np.uint8, offset=16) data = data.reshape(-1,784) return datadef load_fashion_mnist_labels(filename): if not os.path.exists(filename): ...