8000 GitHub - ZhitingHu/python-gradientzoo: Python integration for Gradientzoo - version and share your trained neural network model weights
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Python integration for Gradientzoo - version and share your trained neural network model weights

License

Notifications You must be signed in to change notification settings

ZhitingHu/python-gradientzoo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gradientzoo Python bindings

Documentation Status

This is a Python library for Gradientzoo's API. Loading a pre-trained neural network is easy with Gradientzoo. Here's how easy it is to load a model with Tensorflow (full example below):

import tensorflow as tf
from gradientzoo import TensorflowGradientzoo

# (build MNIST graph here)

with tf.Session() as sess:
    # Load latest weights from Gradientzoo
    TensorflowGradientzoo('ericflo/mnist').load(sess)

    # Graph is now ready to use!

Saving models is similarly straightforward:

import tensorflow as tf
from gradientzoo import TensorflowGradientzoo

# (build MNIST graph here)

with tf.Session() as sess:
    for epoch in xrange(6):
        # Train the model...

        # Save the updated weights out to Gradientzoo
        TensorflowGradientzoo('ericflo/mnist').save(sess)

Features

Supports saving models in Keras, variables in Tensorflow, and networks in Lasagne, and regular old files using Python with your framework of choice.

Installation

You don't need this source code unless you want to modify the package. If you just want to use the Gradientzoo Python bindings, you should run:

pip install --upgrade gradientzoo

or

easy_install --upgrade gradientzoo

See http://www.pip-installer.org/en/latest/index.html for instructions on installing pip. If you are on a system with easy_install but not pip, you can use easy_install instead. If you're not using virtualenv, you may have to prefix those commands with sudo. You can learn more about virtualenv at http://www.virtualenv.org/

To install from source, run:

python setup.py install

Documentation

Please see http://python-gradientzoo.readthedocs.org/ for the most up-to-date documentation or visit a project page to see project-specific instructions, e.g. https://www.gradientzoo.com/ericflo/mnist

Contribute

Support

If you are having issues, please let us know at support@gradientzoo.com

Full Tensorflow Example

import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data, mnist
from gradientzoo import TensorflowGradientzoo

learning_rate = 0.01
batch_size = 100

# Build MNIST graph
images_placeholder = tf.placeholder(tf.float32,
                                    shape=(batch_size, mnist.IMAGE_PIXELS))
labels_placeholder = tf.placeholder(tf.int32, shape=(batch_size))
logits = mnist.<
5F99
span class="pl-c1">inference(images_placeholder, 128, 32)
loss = mnist.loss(logits, labels_placeholder)
train_op = mnist.training(loss, learning_rate)
eval_correct = mnist.evaluation(logits, labels_placeholder)

# Start a Tensorflow session
with tf.Session() as sess:
    # Load latest weights from Gradientzoo
    TensorflowGradientzoo('ericflo/mnist').load(sess)

    # Read in some data
    data_sets = input_data.read_data_sets('data', False)

    # Test the trained network on the dataset
    true_count = 0
    for step in xrange(data_sets.test.num_examples // batch_size):
        images_feed, labels_feed = data_sets.test.next_batch(batch_size, False)

        true_count += sess.run(eval_correct, feed_dict={
            images_placeholder: images_feed,
            labels_placeholder: labels_feed,
        })

    precision = true_count / float(data_sets.test.num_examples)
    print('Num Examples: %d  Num Correct: %d  Precision: %0.04f' %
          (data_sets.test.num_examples, true_count, precision))

About

Python integration for Gradientzoo - version and share your trained neural network model weights

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%
0