Skip to content

Commit

Permalink
Merge pull request greentfrapp#13 from greentfrapp/dev
Browse files Browse the repository at this point in the history
Notebooks restructuring, additional assert checks and kornia freeze
  • Loading branch information
greentfrapp authored Oct 23, 2020
2 parents 19b8cd5 + 99e88fb commit b545d45
Show file tree
Hide file tree
Showing 20 changed files with 21 additions and 7,236 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,29 @@ render.render_vis(model, "mixed4a:476")

## Tutorials

<a href="https://colab.research.google.com/github/greentfrapp/lucent/blob/master/notebooks/tutorial.ipynb">
<img src="https://github.com/greentfrapp/lucent/raw/master/images/tutorial_card.jpg" width="500" alt=""></img></a>
<a href="https://colab.research.google.com/github/greentfrapp/lucent-notebooks/blob/master/notebooks/tutorial.ipynb">
<img src="https://github.com/greentfrapp/lucent-notebooks/raw/master/images/tutorial_card.jpg" width="500" alt=""></img></a>

<a href="https://colab.research.google.com/github/greentfrapp/lucent/blob/master/notebooks/modelzoo.ipynb"><img src="https://github.com/greentfrapp/lucent/raw/master/images/modelzoo_card.jpg" width="500" alt=""></img></a>
<a href="https://colab.research.google.com/github/greentfrapp/lucent-notebooks/blob/master/notebooks/modelzoo.ipynb"><img src="https://github.com/greentfrapp/lucent-notebooks/raw/master/images/modelzoo_card.jpg" width="500" alt=""></img></a>

## Other Notebooks

Here, we have tried to recreate some of the Lucid notebooks!
Here, we have tried to recreate some of the Lucid notebooks! You can also check out the [lucent-notebooks](https://github.com/greentfrapp/lucent-notebooks) repo to clone all the notebooks.

<a href="https://colab.research.google.com/github/greentfrapp/lucent/blob/master/notebooks/diversity.ipynb"><img src="https://github.com/greentfrapp/lucent/raw/master/images/diversity_card.jpg" width="500" alt=""></img></a>
<a href="https://colab.research.google.com/github/greentfrapp/lucent-notebooks/blob/master/notebooks/diversity.ipynb"><img src="https://github.com/greentfrapp/lucent-notebooks/raw/master/images/diversity_card.jpg" width="500" alt=""></img></a>

<a href="https://colab.research.google.com/github/greentfrapp/lucent/blob/master/notebooks/neuron_interaction.ipynb"><img src="https://github.com/greentfrapp/lucent/raw/master/images/neuron_interaction_card.jpg" width="500" alt=""></img></a>
<a href="https://colab.research.google.com/github/greentfrapp/lucent-notebooks/blob/master/notebooks/neuron_interaction.ipynb"><img src="https://github.com/greentfrapp/lucent-notebooks/raw/master/images/neuron_interaction_card.jpg" width="500" alt=""></img></a>

<a href="https://colab.research.google.com/github/greentfrapp/lucent/blob/master/notebooks/feature_inversion.ipynb">
<img src="https://github.com/greentfrapp/lucent/raw/master/images/feature_inversion_card.jpg" width="500" alt=""></img>
<a href="https://colab.research.google.com/github/greentfrapp/lucent-notebooks/blob/master/notebooks/feature_inversion.ipynb">
<img src="https://github.com/greentfrapp/lucent-notebooks/raw/master/images/feature_inversion_card.jpg" width="500" alt=""></img>
</a>

<a href="https://colab.research.google.com/github/greentfrapp/lucent/blob/master/notebooks/style_transfer.ipynb">
<img src="https://github.com/greentfrapp/lucent/raw/master/images/style_transfer_card.jpg" width="500" alt=""></img>
<a href="https://colab.research.google.com/github/greentfrapp/lucent-notebooks/blob/master/notebooks/style_transfer.ipynb">
<img src="https://github.com/greentfrapp/lucent-notebooks/raw/master/images/style_transfer_card.jpg" width="500" alt=""></img>
</a>

<a href="https://colab.research.google.com/github/greentfrapp/lucent/blob/master/notebooks/activation_grids.ipynb">
<img src="https://github.com/greentfrapp/lucent/raw/master/images/activation_grids_card.jpg" width="500" alt=""></img>
<a href="https://colab.research.google.com/github/greentfrapp/lucent-notebooks/blob/master/notebooks/activation_grids.ipynb">
<img src="https://github.com/greentfrapp/lucent-notebooks/raw/master/images/activation_grids_card.jpg" width="500" alt=""></img>
</a>

# Recommended Readings
Expand Down
Binary file removed images/activation_grids_card.jpg
Binary file not shown.
Binary file removed images/diversity_card.jpg
Binary file not shown.
Binary file removed images/feature_inversion_card.jpg
Binary file not shown.
Binary file removed images/modelzoo_card.jpg
Binary file not shown.
Binary file removed images/neuron_interaction_card.jpg
Binary file not shown.
Binary file removed images/style_transfer_card.jpg
Binary file not shown.
Binary file removed images/transfer_big_ben.png
Binary file not shown.
Binary file removed images/transfer_picasso.png
Binary file not shown.
Binary file removed images/transfer_vangogh.png
Binary file not shown.
Binary file removed images/tutorial_card.jpg
Binary file not shown.
12 changes: 8 additions & 4 deletions lucent/optvis/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,13 @@ def hook_layers(net, prefix=[]):

def hook(layer):
if layer == "input":
return image_f()
if layer == "labels":
return list(features.values())[-1].features
return features[layer].features
out = image_f()
elif layer == "labels":
out = list(features.values())[-1].features
else:
assert layer in features, f"Invalid layer {layer}. Retrieve the list of layers with `lucent.modelzoo.util.get_model_layers(model)`."
out = features[layer].features
assert out is not None, "There are no saved feature maps. Make sure to put the model in eval mode, like so: `model.to(device).eval()`. See README for example."
return out

return hook
Loading

0 comments on commit b545d45

Please sign in to comment.