Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add activation grids notebook #4

Merged
merged 5 commits into from
Jun 22, 2020

Conversation

mehdidc
Copy link
Contributor

@mehdidc mehdidc commented May 27, 2020

Issue #3, reproducing activation grids (https://github.com/tensorflow/lucid/blob/master/notebooks/building-blocks/ActivationGrid.ipynb)

It's possible to try it here: https://colab.research.google.com/drive/1pEe-KmXeDJcWQYLOHwcMubS69wVVCHLe#scrollTo=xidm-QrXvL2X

Here are the results so far with inceptionv1 and layer mixed4d:

Some remarks and a question:

  • I added channel_reducer as is from the original repo
  • default transforms in transform.py produce a different size (due to random scaling) each time it is called, then resampling to 224 is done after that to have a fixed size. Is that the same in lucid? I need to debug a little bit in the original repo to be sure to answer that, but please let me know if you have the answer. The reason I ask is that in this specific notebook, the cells in the grid are much smaller than 224. I added an argument "fixed_image_size" to handle this specific case where we want a fixed image size (after resampling) which is not 224.
  • Since all layers are computed and with this commit we can accept smaller images, this means that it's possible to have an exception on higher layers because the image size is not big enough, but it should be fine as long as the layer we are interested in is computed, I handled this exception

@greentfrapp
Copy link
Owner

@mehdidc Thanks so much for the PR! Sample results look good! I'm a little occupied with a paper submission at the moment, but I will definitely take a look at this over the weekend.

@greentfrapp
Copy link
Owner

@mehdidc sorry for the late reply!

Re. the issue on smaller images: for Lucid, I believe because Tensorflow 1.x allows you to just retrieve a specific layer via sess.run, so there is no issue as long as the layer you want is computed. But in our case, we run the entire model, so torch raises an error when you hit the later layers. I think I'm okay with raising an exception for now, so your modification is probably alright!

Two small changes:

  • Could you format the quoted part in the notebook as a quote? i.e. using ">" in markdown
  • Could you add some tests for channel_reducer? You can run the tests with
$ coverage run --source . --omit setup.py -m pytest
$ coverage report -m

Should be good once those are done, I'll take care of adding it to the main README.

Thanks again for the help!!!

- update notebook with markdown quotes
- update notebook with master link to the repo in the installation
- when an undesirable layer is too deep to compute (image is tool), show warning instead of print
@mehdidc
Copy link
Contributor Author

mehdidc commented Jun 15, 2020

Hi @greentfrapp thanks for the remarks, I added some tests + updated notebook quotes + other minor modifications

@greentfrapp
Copy link
Owner

Thanks @mehdidc for the help! I think this looks good to merge and I'll add the title card for the notebook soon!

@greentfrapp greentfrapp merged commit 703546e into greentfrapp:master Jun 22, 2020
@greentfrapp
Copy link
Owner

Closes #3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants