Coder Social home page Coder Social logo

pytorch-mcn's Introduction

pytorch-mcn

A tool for importing trained MatConvNet models into Pytorch (if you were hoping to go the other way, try mcnPyTorch).

Demo

To run the importer, set the path to the MatConvNet model and supply an output directory (where the imported PyTorch models will be stored) in the importer.sh script. There are a few examples in the script which can be commented/uncommented to run as a demo. Then run bash importer.sh.

Imported Models

A number of standard models have been imported and verified, and can be found here.

Verification

Verifying an imported model requires MATLAB and a copy of MatConvNet (the specific dependencies are given in compare/startup.m). The process is as follows:

  1. Run the compare/featureDumper.m script to dump intermediate features from the original MatConvNet model to disk.
  2. Import model to PyTorch in debug_mode (an option that can be set in importer.sh. This will generate additional source code in the PyTorch model definition that stores every intermediate tensor computed by the network.
  3. Run the compare/compare_models.py script, which will perform a numerical comparison between the tensors.

Notes

Model conversion between frameworks can be challenging, because the layers and modules of each framework do not have an exact correspondence. As a result, there is often a bit of work involved in the conversion process, particularly for non-standard architectures.

This tool requires at least Python 3.5 and PyTorch 0.3.0 (by default, ipython will be used, but you can switch to standard python by changing a config variable in importer.sh). The tool expects the MatConvNet models to be in dagnn format (the ensure_dags.m script converts models to this format from SimpleNN if required).

Ideally in future the model conversion process will run via onnx but it seems that currently quite a lot of support is missing for required functionality. The plan is therefore to update the converter when possible.

pytorch-mcn's People

Contributors

albanie avatar

Watchers

 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.