GithubHelp home page GithubHelp logo

ulkursln / nn-transfer Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gzuidhof/nn-transfer

0.0 1.0 0.0 36 KB

Convert trained PyTorch models to Keras, and the other way around

License: MIT License

Python 73.57% Jupyter Notebook 26.43%

nn-transfer's Introduction

nn-transfer

Build Status

NOTE: This repository does not seem to yield the correct output anymore with the latest versions of Keras and PyTorch. Take care to verify the results or use an alternative method for conversion.

This repository contains utilities for converting PyTorch models to Keras and the other way around. More specifically, it allows you to copy the weights from a PyTorch model to an identical model in Keras and vice-versa.

From Keras you can then run it on the TensorFlow, Theano and CNTK backend. You can also convert it to a pure TensorFlow model (see [1] and [2]), which allows you to choose more robust deployment options in the cloud, or even mobile devices. From Keras you can also do inference in browsers with keras-js.

Installation

Clone this repository, and simply run

pip install .

You need to have PyTorch and torchvision installed beforehand, see the PyTorch website for how to easily install that.

Tests

To run the unit and integration tests:

python setup.py test
# OR, if you have nose2 installed,
nose2

There is also Travis CI which will automatically build every commit, see the button at the top of the readme. You can test the direction of weight transfer individually using the TEST_TRANSFER_DIRECTION environment variable, see .travis.yml.

How to use

See example.ipynb for a small tutorial on how to use this library.

Code guidelines

  • This repository is fully PEP8 compliant, I recommend flake8.
  • It works for both Python 2 and 3.

nn-transfer's People

Contributors

gzuidhof avatar jvanvugt avatar

Watchers

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