Git Product home page Git Product logo

tensorgraph's Introduction

tensorgraph

Tensorgraph is an TensorFlow example to show

  • How to generate checkpoint, graph.pb, tensorboard.
  • How to use checkpoint and graph.pb to merge to freeze graph. (not finished yet)
  • How to load graph with tensorflow c++ api and do the prediction.

More detailed description in my blog post

Requirement

gengraph

How to generate checkpoint, graph.pb, tensorboard.
The directory struct is

mnist.py
board/
models/

After run

$ python mnist.py

The directory struct will be expected to

mnist.py
board/
    event.out.tfevents
models/
    graph.pb
    model.ckpt
Mnist_data/
    ...

generate frozen graph

From Tensorflow official guide says that:

What this does is load the GraphDef, pull in the values for all the variables from the latest checkpoint file, and then replace each Variable op with a Const that has the numerical data for the weights stored in its attributes It then strips away all the extraneous nodes that aren't used for forward inference, and saves out the resulting GraphDef into an output file

Hence, we do the following steps to generate frozen graph

bazel build tensorflow/python/tools:freeze_graph && \
bazel-bin/tensorflow/python/tools/freeze_graph \
--input_graph=graph.pb \
--input_checkpoint=model.ckpt \
--output_graph=/tmp/frozen_graph.pb --output_node_names=softmax

loadgraph

How to load graph with tensorflow c++ api and do the prediction.
Put the directory to tensorflow source code. Here is the final directory structure:

tensorflow/tensorflow/loadgraph
tensorflow/tensorflow/loadgraph/mnist.cc
tensorflow/tensorflow/loadgraph/MNIST.h
tensorflow/tensorflow/loadgraph/BUILD

Compile and Run

From inside the TensorFlow project folder call $bazel build tensorflow/tensorflow/loadgraph:mnistpredict From the repository root, go into bazel-bin/tensorflow/loadgraph. Copy the frozen_graph.pb and Mnist_data to bazel-bin/tensorflow/loadgraph Then run ./mnistpredict and check the output

Reference

MNIST_Loader
Load graph with tensorflow c++ api

tensorgraph's People

Contributors

jackytung avatar seanny123 avatar codec-abc avatar

Stargazers

Leo Ota avatar TaeYoung Kim avatar  avatar  avatar Wonseok Jeon avatar sloth avatar Sheng-Chi Liu avatar  avatar Dzianis Pirshtuk avatar Ryuichi Inaba avatar Chan Woo Kim avatar Dan Stieglitz avatar Roger Chenying Hsieh avatar Anish Singh Walia avatar Nikolay Voronchikhin avatar Tang Lee avatar Jacob Manning avatar Kiki R avatar  avatar  avatar Ale Solano avatar  avatar Philippe Gagné avatar beodeulpiri avatar  avatar Leo Chen avatar Tomi Maila avatar rwx avatar Yuki BAN avatar Mauri de Souza Meneguzzo avatar Daun avatar qtson avatar  avatar  avatar  avatar Peter Klobusnik avatar  avatar

Watchers

James Cloos avatar Huajun avatar Kiki R avatar Wei Cheng avatar  avatar

tensorgraph's Issues

filename maybe wrong in line 68 and 69 of MNIST.h?

The files in MNIST_data directory shoud be t10k-images.idx3-ubyte, t10k-labels.idx1-ubyte, train-images.idx3-ubyte, train-labels.idx1-ubyte respectively, rather than t10k-images-idx3-ubyte, t10k-labels-idx1-ubyte, train-images-idx3-ubyte, train-labels-idx1-ubyte.

ERROR parsing training data

I get error when I run the c++ code
ERROR: parsing training data
ERROR: parsing testing data
terminate called after throwing an instance of 'std::out_of_range'
what(): vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
Aborted (core dumped)
_

I think the error is caused by the wrong MNIST dataset location, where actually I should place the MNIST dataset ?

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.