Skip to content

elenakelly/Convolutional-Autoencoders

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 

Repository files navigation

Autoencoder

An autoencoder (AE) is a neural network that is trained to copy its input to its output.
It has one or more hidden layers that each describe a code used to represent the input.
The network may be viewed as consisting of two parts:
an encoder h=f(x) that produces the code and a decoder that produces a reconstruction of the datar=g(h).

Encoder

The encoder is tasked with finding a (usually) reduced representation of the data, extracting the most prominentfeatures of the original data and representing the input in terms of these features in a way the Decoder can understand.

Decoder

The Decoder learns to read these codes and regenerate the data from them. The entire AE aims to minimize a loss-function while reconstructing.

In their simplest form encoder and decoder are fully-connected feedforward neuralnetworks.
When the inputs are images, it makes sense to use convolutional neural networks (CNNs) instead, obtaininga convolutional autoencoder (CAE).

Convolutional Autoencoder

A CAE uses the convolutional filters to extract features. CAEs learn to encode the input as a combination ofautonomously learned signals and then to reconstruct the input from this encoding.
CAEs learn in what can be seenas an unsupervised learning setup, since they don’t require labels and instead aim to reconstruct the input. Theoutput is evaluated by comparing the reconstructed image by the original one, using a Mean Squared Error (MSE)cost function.

Dataset

We will be using the CIFAR-10 dataset: •CIFAR-10 dataset (https://www.cs.toronto.edu/ ̃kriz/cifar.html).

Architecture

And the architect we are using is:

download

  1. Reconstruction:
  • Dividing the dataset into training (80%), validation (10%) and test (10%).
  • Normaling the data.
  • Implementing the autoencoder network specified above.
  • Runing the training and ploting the evolution of the error with epochs.
  • Reporting also the test error.
  1. Colorization:
  • Adapting the network from the previous part such that it learns to reconstruct colors by feeding in gray scale images but predicting all RGB channels.
  • As a starting point, the hyperparameters are used (including the network architecture) that can identified to yield the best performance.
  • Reporting the results and reason about potential shortcomings of the network.

Installation

The program is in Jupyter Notebook
In order to use the code you need to install the following packages

  1. Typical libraries
import numpy as np
import matplotlib.pyplot as plt
import tensorflow
  1. For the dataset
 from keras.datasets import cifar10
  1. For the neural network
from keras.utils import np_utils #encoding to transform the labels in categorical
from keras.layers import Input, Dense, Conv2D, MaxPooling2D, #import the layers 
from keras.layers import Dropout, Flatten, UpSampling2D #import the layers 
from keras.models import Sequential #import the model
from tensorflow.keras import optimizers #import the optimizer
from keras.preprocessing import image #for visualisation of the image data
from keras import backend as K #for cleaning the memory
from keras.callbacks import Callback #import the callback

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published