Coder Social home page Coder Social logo

visual-backprop-mxnet's Introduction

Implementation of VisualBackProp for MXNet

This repo contains an implementation of VisualBackProp for MXNet.

Requirements

  1. Make sure to use Python 3 (the code creating the symbol for VisualBackProp should also work with Python2)
  2. Install MXNet as shown here. Make sure that you have at least MXNet v0.10.0!
  3. Install further requirements by issuing pip install -r requirements.txt
  4. If you want to use the show_progress.py script you also need to install tkinter (in case the script does not work right from the start)

Usage

The file vis_backprop_test.py contains a sample that trains MNIST and performs VisualBackprop on every forward pass. In order to use the script, you have to do the following:

  1. start the script show_progress.py by issuing python show_progress.py
  2. start the training of the network by issuing python vis_backprop_test.py
  • if you want to change some options you can get a list of all supported by options by adding -h to the python command.

Adding VisualBackProp to your own code

Adding VisualBackProp to your own code ist quite easy. You have to perform the following steps:

  1. adapt your symbol definition, by adding a call to insights.build_visual_backprop_symbol after the activation of the convolutional layer you want to visualize. (see this line)
  2. keep the returned visualization symbol for the visualization pass.
  3. If you want to use VisualBackProp during the training, for each training step, you have to create an instance of the VisualBackpropPlotter class, providing an ip and port for the visualization endpoint. (see this line)
  4. get one sample image where you want to visualize the convolution (see this line).
  5. add a new batch_end_callback to your model, by calling the method get_callback of the created VisualBackpropPlotter object (see this line).
  6. start the show_progress.py tool, that you can find in the utils directory, by issuing the following command: python show_progress.py. (This tool is the visualization endpoint)
  7. Sit back and enjoy!

How does it work?

insights.build_visual_backprop_symbol adds a new subgraph to the computational graph that performs the necessary operations for VisualBackProp (see the paper for more details). During a forward pass MXNet calls the callback implemented in VisualBackpropPlotter. This callback copies the current params and performs a forward pass with the given input data. After this forward pass, the output generated by the VisualBackProp branch is extracted and converted into an image. Together with the original image, this image is send to the visualization endpoint.

You can also use this implementation during testing, by performing the exact same steps as the VisualBackpropPlotter you just don't need to send the resulting image to someone, but can save it to the disk.

License

This code is licensed under the GPLv3 license.

visual-backprop-mxnet's People

Contributors

bartzi avatar pagey 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.