Giter Site home page Giter Site logo

featurevis_mod's Introduction

featurevis

Visualize features that activate neurons via gradient ascent.

Installation

After installing PyTorch, run:

pip3 install git+https://github.com/cajal/featurevis.git

Usage

feature_vis.gradient_ascent receives a function $f(x)$ to optimize, an initial estimate $x$ and some optimization parameters like step size and number of iterations.

Optionally, it can receive any of: a differentiable transform $t(x)$ to apply to $x$ at each iteration before evaluating $f$, a differentiable regularization $r(x)$ to be minimized, i.e., optimization becomes:

$$\arg\max_{x} f(t(x)) - r(t(x))\text{ ,}$$

a gradient_f function $g(x)$ to apply to the gradient before applying the update and a post_update function $p(x)$ to apply to the updated $x$ after each iteration:

$$ x_{t+1} = p\left(x_t + \alpha g\left(\frac{\delta f}{\delta x_t}\right)\right)\text{.} $$

These functions ($t$, $r$, $g$ and $p$) should cover the most common scenarios when creating feature visualizations for neural network models. We provide implementations for many of these commonly used functions in feature_vis.ops.

You can check the Examples.ipynb notebook to see how to visualize features from a VGG network or real neurons[1] under different configurations.

[1]: Models for real neurons come from a private repo but the examples should still be a useful starting point.

featurevis_mod's People

Contributors

ecobost avatar lucabaroni 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.