Giter VIP home page Giter VIP logo

siamese_tf_mnist's Introduction

Implementing Siamese Network using Tensorflow with MNIST

I have been interested in Siamese network. To my understanding, it is one way of dealing with weakly supervised problems. Its beauty lies in its simple scheme. It seems Siamese networks (and Triplet network) have been popularly used in many applications such as face similarity and image matching. A web page motivates me to implement a similar Siamese network using Tensorflow.

These codes here embed hand-written digits into 2D space. A loss function controls the embedding to be closer for digits in the same class and further for digits in the different classes. I borrowed visualization part from the original source with a little modification (including colors).

I kept codes minimal for my personal experiments (e.g., different architectures or loss functions).

  • run.py : nothing but a wrapper for running.
  • inference.py : architecture and loss definition. you can modify as you want.
  • visualize.py : visualizes result.

You can simply run :

$ python run.py
...
step 34750: loss 0.179
step 34760: loss 0.113
step 34770: loss 0.078
...

This will download and extract MNIST dataset (once downloaded, it will skip downloading next time). Once training done, a result will appear as in the image above. It saves an intermediate model regularly (with names model.*) while training.

When you run run.py, if an model file exists, you will be asked if you want to load it and continue training from that status. no will start training from the scratch.

$ python run.py
We found model.ckpt file. Do you want to load it [yes/no]? yes

For your convenience, while training, embedding results are keeping updated in embed.txt. So you can see an resulting embedding anytime (by stopping training or with a separate cmd/shell while training), using

$ python visualize.py

Please let me know if there are mistakes or comments. Thanks!

Youngwook Paul Kwon

siamese_tf_mnist's People

Contributors

ywpkwon avatar colemurray 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.