Comments (3)
I've noticed this, too.
from lucent.
This issue stems from the fact that the registered forward_hooks
(they are used to grab feature maps from the hidden layers) are not properly cleaned up before render_vis
returns.
This is quite a serious bug, although it is not harmful to the correctness of the visualizations. After many iterations, the sub modules accumulate hundreds of these hooks, that get called after every forward()
call on the model. This even impacts any other code that uses the model after calling render_vis.
A quick and dirty fix is to clear all forward_hooks
from the model, after each call to render_vis, like so:
from collections import OrderedDict
def remove_all_forward_hooks(model):
for _, child in model._modules.items():
if child is not None:
if hasattr(child, "_forward_hooks"):
child._forward_hooks = OrderedDict()
remove_all_forward_hooks(child)
# call this after render_vis
remove_all_forward_hooks(your_torch_model)
(I took this code from here)
Of course, a proper fix to this should be patched directly into the library, cleaning up the model by removing only the hooks actually created by the render_vis
function (the above code removes ALL hooks, even those unrelated to Lucent / render_vis
).
from lucent.
Thanks @antoninogreco and @tshead2 for reporting this! And thanks to @TomasWilson for the suggested fix!
This should be fixed with #52 where the created module hooks are cleared after each render_vis run.
from lucent.
Related Issues (20)
- Visuals losing contrast over time HOT 1
- PyTorch 1.7 support HOT 1
- Installing lucent causes pytorch downgrade HOT 1
- Input with more than 3 channels HOT 9
- ValueError in Render HOT 4
- Generating a batch of optimal stimuli, one for each unit in a layer HOT 3
- Grayscale Optimal stimuli HOT 1
- Change torch device
- get raw_activations HOT 2
- pytorch version rollover breaks some version checking logic
- Propagating KeyboardInterrupt in render_vis
- Neuron has grey optimal input
- Low GPU utilization
- activation grid for hierarchical custom model HOT 1
- Lucent handles greyscale images in function view incorrectly
- Code Breaks as GPU Index > 0 HOT 2
- Is there a way to implement Semi-Transparent Patterns available in lucid?
- Is this repository still being maintained or is it dead?
- show() and export() give different images
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lucent.