October 2018
Intermediate to advanced
472 pages
10h 57m
English
This module implements training an autoencoder on MNIST data:
"""This module implements a convolution autoencoder on MNIST data."""import numpy as npimport matplotlib.pyplot as pltfrom keras.datasets import mnist(X_train, y_train), (X_test, y_test) = mnist.load_data()from keras.layers import Conv2D, MaxPooling2D, UpSampling2Dfrom keras.models import Model, Sequentialfrom keras.optimizers import Adamfrom keras import backend as k# for resizing imagesfrom scipy.misc import imresizedef reshape(x): """Reshape images to 14*14""" img = imresize(x.reshape(28,28), (14, 14)) return img# create 14*14 low resolution train and test imagesXX_train = np.array([*map(reshape, X_train.astype(float))])XX_test = np.array([*map(reshape, ...
Read now
Unlock full access