Git Product home page Git Product logo

thegodone / autoencoder-tensorboard-t-sne Goto Github PK

View Code? Open in Web Editor NEW

This project forked from vooban/autoencoder-tensorboard-t-sne

0.0 2.0 0.0 24.29 MB

Plugging TensorBoard in an autoencoder on the MNIST dataset for demonstrating t-SNE embeddings visualization of unsupervised machine learning.

Home Page: http://vooban.com/en/tips-articles-geek-stuff/hyperopt-tutorial-for-optimizing-neural-networks-hyperparameters/

License: MIT License

Python 99.61% Shell 0.39%

autoencoder-tensorboard-t-sne's Introduction

Visualizing embeddings of a TensorFlow autoencoder in TensorBoard with t-SNE

Plugging TensorBoard in an autoencoder on the MNIST dataset for demonstrating t-SNE embeddings visualization of unsupervised machine learning.

Note that what t-SNE gives us are embeddings too. To be clear, in this project, we have two types of embeddings:

  • We embed and compress the dataset with an autoencoder. This is an unsupervised neural compression of our data and such neural compressions can reveal to be very useful for various tasks where unlabeled data is available.
  • We embed the autoencoder's embedding with t-SNE as a mean to further compress the information to visualize what's going on in the autoencoder's embeddings. This is really a visualization of what's going on.

Embedding with an autoencoder

The nuance here compared to running t-SNE embeddings on the raw mnist input images is that we visualize what the encoder has managed to encode in its compressed, inner layer representation (called "code" in the picture below, and often called "embedding").

Autoencoder structure https://en.wikipedia.org/wiki/File:Autoencoder_structure.png

The encoder we train here is very simple just to give an example with a code of 64 neurons wide. Ideally, it would contain convolutions and would be more optimized.

Visualizing with t-SNE

You may want to read this great article on how to interpret the results of t-SNE. Here is how does t-SNE looks like with the default parameters (perplexity of 25 and learning rate of 10):

t-SNE visualization with TensorBoard for an Autoencoder's embedding, trained on MNIST

Note that a Principal Component Analysis (PCA) can be used in a similar way. However, a PCA is a bit more interesting mathematically than t-SNE, despite t-SNE looks better to the human eye. Here is how a PCA looks like, representing 19.8% of the variance:

PCA visualization with TensorBoard for an Autoencoder's embedding, trained on MNIST

To run the code

Step 1

Run:

python3 autoencoder_t-sne.py

Step 2

./run_tensorboard.sh

You could also simply run the same thing that's contained in the .sh:

tensorboard --logdir=logs --port="6006"

That simply runs TensorBoard on its default port.

Step 3

Browse to localhost:6006 or http://0.0.0.0:6006/ and then head to the "embedding" tab.

Choose to color by label and then you may play with t-SNE or PCA embeddings!

Enjoy!

autoencoder-tensorboard-t-sne's People

Contributors

guillaume-chevalier avatar ormagardskvaedi avatar

Watchers

 avatar  avatar

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.