Giter Site home page Giter Site logo

tf-queues-full-mnist-example's Introduction

A Complete Example of Tensorflow Queues

The story behind this is that I kept seeing mention of Tensorflow Queues and that feed_dict shouldn't be used in serious Tensorflow code, but the documentation didn't have a complete example of how to use them. This post was the most helpful resource I found when I was learning how to use Queues.

I have provided a complete example (albeit simple) that covers all the way from cleaning the data to evaluating the model on a test set, all the while using Tensorflow Queues. It's pretty neat when you realize you don't have to use feed_dict because the underlying Session graph already knows where to get your train/validation/test data!

On my NVIDIA GTX 1080, this takes up about 6 GB since the data can be transferred directly onto the GPU. The model itself is only a few hundred MBs. This is much faster than having to copy each mini-batch from the CPU -> GPU each time you call feed_dict; in fact, the data is copied over twice.

This example is a modified version of the Convolutional Neural Network from this tutorial.

The MNIST dataset is included under MNIST_data. Run

python mnist-to-jpg.py

to unpack the data, then do

python cnn.py

It should take about half an hour to run on a CPU, or a few minutes on a GPU.

The code has been tested with Python 3.5 and Tensorflow 1.1.

If using Anaconda, make sure to have scipy and Pillow also installed.

tf-queues-full-mnist-example's People

Contributors

pemami4911 avatar

Watchers

James Cloos avatar zhu 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.