Skip to content

Conversation

@ProGamerGov
Copy link
Contributor

@ProGamerGov ProGamerGov commented Apr 21, 2025

So this project got left on the back burner for a while but I've brought it back. The original plan was to either merge it into Captum or spin it out as a separate library under the PyTorch umbrella. The project was almost ready for release before it was paused, and I have since pushed it closer to full release quality.

The ReadMe for the module can be found here: https://github.com/ProGamerGov/captum/tree/master-optim/captum/optim

This PR contains all the following PR merged together:

#983
#968
#967
#966
#965
#961
#960
#957
#955
#955
#951
#949
#946
#945
#943
#927
#828

The module was developed based on this initial starting PR: #412

The last PR reviewed by the Captum team, was this one: #935

As part of this project, numerous improvements were made to Captum and the libraries that it is dependent on:

)

* Improve ModuleOutputsHook, testing coverage, & fix bug

* Added the `_remove_all_forward_hooks` function for easy cleanup and removal of hooks without requiring their handles.

* Changed `ModuleOutputHook`'s forward hook function name from `forward_hook` to `module_outputs_forward_hook` to allow for easy removal of only hooks using that hook function.

* `ModuleOutputHook`'s initialization function now runs the `_remove_all_forward_hooks` function on targets, and only removes the hooks created by `ModuleOutputHook` to avoid breaking PyTorch.

* Added the `_count_forward_hooks` function for easy testing of hook creation & removal functionality.

* Added tests for verifying that the 'ghost hook' bug has been fixed, and that the new function is working correctly.

* Added tests for `ModuleOutputsHook`. Previously we had no tests for this module.

* Make hook fix optional

* Remove hacky hook fix

* Lint: Fix import order
…o ImageTensor (meta-pytorch#839)

* Add better colorspace support, image grids, & user agent to ImageTensor

* Added color space support to `save_tensor_as_image` & `ImageTensor.export`.
* Added image grid creation support to `ImageTensor.export` , `ImageTensor.show` , `show` & `save_tensor_as_image` via a new `make_grid_image` function.
* Added user agent to `ImageTensor.open` as sites like Wikipedia require user agents.

* Add description to make_grid_image tests

* `nrow` -> `images_per_row`

* Remove test description

It's no longer required now that the images_per_row variable was renamed.

* Add missing tests

* Fix test
* Ensure testing coverage is as high as possible.
* Simplified code with new `rmodule_op` function.
* Removed the NumPy import from loss testing.
* Fix duplicated target bug

* Fix duplicated target bug in `sum_loss_list` & `collect_activations`

* Add ToDo comment for target handling
* Wrap all remaining `torch.__version__` calls in `version.parse`.
* Remove unused version check in `typing.py`.
* Expose `MaxPool2dRelaxed` to users so that tutorials using it work.
* Expose `dataset` module to users.
* Fixed `show` & `save_tensor_as_image` docs.
* Improve efficiency of the `FacetLoss` objective.
@craymichael
Copy link
Contributor

Hi @ProGamerGov, I wanted to leave a quick comment - thank you for bringing this project back to light! This is a big and exciting contribution, but will definitely take us some time to review it thoroughly. It's busy right now, but I will discuss this with the team and plan how we will deliver a timely review. We appreciate your patience and contributions.

@ProGamerGov
Copy link
Contributor Author

@craymichael Awesome, thank you for the update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants