Giter VIP home page Giter VIP logo

graftr's Introduction

graftr

PyPI Release License

An interactive shell to view and edit PyTorch checkpoints.

graftr cast

graftr can be used to remove, rename, and move around the layers and parameters of your saved model. It's also a handy tool to peek into the structure of pre-trained PyTorch models that you can find online (e.g. Transformer, DCGAN, etc.).

The screencast above shows an example of taking a pre-trained Densenet and preparing it for integration into a larger model. We remove the final classification layer and move the feature extractor into its own densenet module.

Install

pip install graftr

Documentation

graftr presents a hierarchical directory structure for state_dicts and parameters in your checkpoint. You can list (ls), move/rename (mv), and print (cat) parameters. And, of course, you can navigate (cd) through the hierarchy. It also supports standard shell beahvior like command history, up-arrow, tab-completion, etc.

All changes are kept in-memory until you're ready to write them back to your checkpoint with save.

Supported commands

  • cd - change working directory.
  • pwd - print working directory.
  • ls - list directory contents.
  • cat - print the contents of a value or directory.
  • mv - move/rename value or directory.
  • rm - remove value or directory.
  • parameters - print the number of model parameters under a directory.
  • shape - print tensor shape.
  • device - get or set the device of a tensor or group of tensors.
  • save - write back changes to disk.
  • where - print the location on disk where changes will be saved.
  • exit - exits the shell.

FAQ

Should this be a mountable user-mode filesystem instead?

Maybe? Some operations (e.g. shape, parameters, device) don't map easily onto standard filesystem operations. On the other hand, it would be interesting to insert/extract tensors by copying NumPy files in and out of the virtual filesystem.

graftr's People

Contributors

sharvil 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.