Skip to main content

Feature visualization to make deep neural networks more interpretable

Project description

torch-dreams

Making deep neural networks more interpretable, one octave at a time.

Open In Colab

pip install torch-dreams --upgrade

Contents:

Quick start

This is a very simple example. For advanced functionalities like simultaneous optimization of channels/layers/units, check out the quick start notebook

  • Importing the good stuff
import os
import matplotlib.pyplot as plt
import torchvision.models as models 
from torch_dreams.dreamer import dreamer
  • Initiating torch_dreams.dreamer and selecting a layer to optimize on
model = models.inception_v3(pretrained=True)
dreamy_boi = dreamer(model)

layer = model.Mixed_5d
layers_to_use = [layer]  ## feel free to add more layers
  • Showtime
os.system("wget https://raw.githubusercontent.com/Mayukhdeb/torch-dreams/master/images/noise.jpg")

out_single_layer = dreamy_boi.deep_dream(
    image_path = "noise.jpg",
    layers = layers_to_use,
    octave_scale = 1.3,
    num_octaves = 7,
    iterations = 100,
    lr = 0.9
)

plt.imshow(out_single_layer)
plt.show()

Optimizing noise to activate multiple channels simultaneously within the inceptionv3

Feature visualization through combined optimization of channels

Changes under way:

  1. Expandtorch_dreams to facilitate research in neural network interpretability.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for torch-dreams, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size torch_dreams-0.1.0-py3-none-any.whl (11.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size torch-dreams-0.1.0.tar.gz (9.9 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page