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.

Source Distribution

torch-dreams-0.1.0.tar.gz (9.9 kB view hashes)

Uploaded Source

Built Distribution

torch_dreams-0.1.0-py3-none-any.whl (11.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page