Code Monkey home page Code Monkey logo

conv-autoencoder's Introduction

Convolutional Autoencoder (CAE) in Python

An implementation of a convolutional autoencoder in python and keras.

Installation

pip install cae

Usage

from cae import cae
import numpy as np

# create a fake dataset, here: 1000 random 224x224 RGB images
images = np.random.normal(size=(1000, 224, 224, 3))

latent_dim = 8 # desired latent dimensionality

model = cae(images.shape[1:], latent_dim) # there are a number of **kwargs
                                          # parameters that are likely
                                          # worth tuning!!!

# TRAIN THE NETWORK
model.fit(images)

# SAVE THE WEIGHTS FOR EASY RELOADING LATER WITH model.load_weights(path)
model.save_weights('PATH/TO/SAVE/')

Final words

cae.py contains the implementation, which is tested on the MNIST dataset in mnist_test.ipynb.

In general, auto-encoders map an input x to a latent representation y (generally in a much smaller dimensional space), using deterministic functions of the type y = sigma(Wx+b). In order to encode images, it is useful to implement a convolutional architecture. Here, we utilize convolutional layers and max-pooling layers (which allow translation-invariant representations), followed by a flattening and dense layer to encode the images in a reduced-dimensional space. For decoding, you essentially need to perform the inverse operation. For more information on CAEs, consult e.g. http://people.idsia.ch/~ciresan/data/icann2011.pdf.

conv-autoencoder's People

Contributors

jmmanley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

conv-autoencoder's Issues

Default params not working

Hi there, I tried creating an instance of the class ConvAutoEncoder with the default parameters and the execution failed.

how to change the below code with own data set

load MNIST dataset

import urllib, gzip, pickle

mnistfile = 'mnist.pkl.gz'
if not os.path.isfile(mnistfile):
url = urllib.request.URLopener()
url.retrieve("http://deeplearning.net/data/mnist/mnist.pkl.gz", mnistfile)
f = gzip.open(mnistfile, 'rb')

training_set, validation_set, testing_set = pickle.load(f, encoding='latin1')

f.close()

X_train, y_train = training_set
X_validate, y_validate = validation_set
X_test, y_test = testing_set

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.