visualizing-cnn-feature-maps icon indicating copy to clipboard operation
visualizing-cnn-feature-maps copied to clipboard

Unified, centralized and simplified code; added CPU option

Open mbuet2ner opened this issue 6 years ago • 5 comments

Here are some things I added/ changed:

  • dedicated filtervisualizer.py file
  • dedicated plot_reconstructions.py file
  • easier accessible due to streamlined functions. Easier to use other neural nets, without changing too much code.
  • added CPU option
  • removed unused imports, codes, parameters
  • don't overwrite built in filter function
  • pep8 guidelines
  • f strings where applicable
  • removed imgur code (I am not sure if it is really necessary for the task)

Things I have not changed yet, but will do in the future:

  • vgg16 and resnet34 part 2 notebooks

Thus, it should be much easier to change things in the future/ migrate to new fastai version.

mbuet2ner avatar Sep 21 '19 20:09 mbuet2ner

Check out this pull request on  ReviewNB

You'll be able to see Jupyter notebook diff and discuss changes. Powered by ReviewNB.

@fg91 sorry for the mess. I know it is hard to review, because it combines quite a lot of changes in one PR. Should I make several pull requests out of it?

mbuet2ner avatar Sep 27 '19 11:09 mbuet2ner

Hey, sorry it took me so long to react. First of all, thank you for taking the time to improve this tutorial!

Would you be willing to change the following?

  • The experiments folder contains additional notebooks provided by a reader of the blog post, so I would like to keep the FilterVisualizer separated from it. Could you please move the filtervisualizer.py out of the experiments folder? The plot_reconstructions.py can stay in the experiments folder as it is only used for the additional experiments...
  • Would you be willing to simplify the Calculate_mean_activation_per_filter_in_specific_layer_given_an_image.ipynb using the most_activated method from FiterVisualizer?

Thanks!

Fabio

fg91 avatar Sep 27 '19 12:09 fg91

I finally addressed your proposed changes :tada: :

  • filtervisualizer.py is now in root. See 12ebf75
  • Calculate_mean_activation_per_filter_in_specific_layer_given_an_image.ipynb now uses filtervisualizer.py. See 9b4b794
  • train_tfms and val_tfms are now instance attributes. See 84ea7cb
  • FilterVisualizer.most_activated() method does not print any mean_act at all (I do not think it is necessary?). Especially no activations.features[0, 5] :grin: . See 9b4b794

mbuet2ner avatar Oct 12 '19 17:10 mbuet2ner

@fg91 If there is anything else you want me to change, just let me know.

mbuet2ner avatar Nov 24 '19 09:11 mbuet2ner