Skip to content

add model tutorial #642

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

Merged
merged 644 commits into from
Mar 30, 2025
Merged

add model tutorial #642

merged 644 commits into from
Mar 30, 2025

Conversation

ProGamerGov
Copy link
Owner

No description provided.

ProGamerGov and others added 30 commits January 23, 2021 19:44
* Also added a missing type hint & updated citation.
* Also made improvements to top channel section of the notebook.
Optim-wip: Add model linearization, and expanded weights spatial positions
ProGamerGov and others added 29 commits March 23, 2022 10:02
…ayers-bug

Optim-wip: Fix issue with `get_model_layers`
Optim-wip: Fix bug with nn.Sequential targets
* Add class activation atlas tutorial notebook

* Changes based on feedback

* Changes based on feedback

* More changes based on feedback

* TSNE -> t-SNE
* Added axes labels to second xy graph.

* Changes to first graph based on feedback
* Fixed the WeightVisualization notebook so that it works with the latest version of the optim module.

* Updated the WeightVisualization notebook to use loss comprehension for faster rendering times.
…ations (pytorch#821)

* Add JIT support to most transforms

* Additional improvements

* JIT support for `center_crop`.
* Improve some transform tests.
* Fix `RandomCrop` transform bug.

* Fix Mypy bug

* Interpolation based RandomScale & Other Improvements

* Replace Affine `RandomScale` with Interpolation based variant. Renamed old variant to `RandomScaleAffine`.
* `CenterCrop` & `center_crop` now use padding if the crop size is larger than the input dimensions.
* Add distributions support to both versions of `RandomScale`.
* Improve transform tests.

* NumSeqOrTensorType -> NumSeqOrTensorOrProbDistType

* Add `torch.distributions.distribution.Distribution` to `NumSeqOrTensorType` type hint.

* Add TransformationRobustness transform& fix bug

* Added `TransformationRobustness()` transform.
* Fixed bug with `center_crop` padding code, and added related tests to `center_crop` & `CenterCrop`.

* Fix center crop JIT tests

* Add asserts & more tests for RandomScale transforms

* Add JIT support for ToRGB, NaturalImage, & FFTImage

* Add JIT support `NaturalImage`, `FFTImage`, & `PixelImage`.
* Added proper JIT support for `ToRGB`.
* Improved `NaturalImage` & `FFTImage` tests, and test coverage.

* Add ImageParameterization Instance support for NaturalImage

* Added `ImageParameterization` instance support for `NaturalImage`. This improvement should make it easier to use parameterization enhancements like SharedImage, and will be helpful for custom parameterizations that don't use the standard input variable set (size, channels, batch, & init).
* Added asserts to verify `NaturalImage` parameterization inputs are instances or types of `ImageParameterization`.

* Support ToRGB with no named dimensions

This should make it easier to work with the ToRGB module as many PyTorch functions still don't work with named dimensions yet.

* Allow more than 4 channels in ToRGB

* The maximum of 4 channels isn't required as we ignore all channels after 3.

* Add assert check to `RandomScale`'s mode variable

The `linear` mode only supports 3D inputs, and `trilinear` only supports 5D inputs. RandomScale only uses 4D inputs, so only `nearest`, `bilinear`, `bicubic`, & `area` are supported.

* Change assert to check for unsupported RandomScale mode options

* Change `RandomRotation` type hint & add `RandomRotation` to `TransformationRobustness`

* Change `RandomRotation` type hint from `NumSeqOrTensorType` to `NumSeqOrTensorOrProbDistType`.
* Uncomment `RandomRotation` from `TransformationRobustness` & tests.
Merge master branch into optim-wip
* Removed test version checks for versions below 1.6.0.
* `AssertArrayAlmostEqual` -> `AssertTensorAlmostEqual`
* General linting changes / fixes.
Optim-wip: Merge master branch into optim-wip
…lename (pytorch#822)

* Fix the Channel Attr notebook image download & metadata filename

* Fix ChannelAttr notebook
* Miscellaneous Changes & Fixes

* Add missing docs

* `get_model_layers`, `collect_activations`, `Conv2dSame`, & `get_neuron_pos` were all missing documentation.

* Fix `utils/image` tests and add missing `_dot_cossim` tests

* Fixed `image_cov` and the dataset tests.
* Renamed `utils/image/dataset.py` to `utils/image/test_dataset.py` as the lack of a `test_` prefix was causing the tests not to be run.
* Renamed `utils/image/common.py` to `utils/image/test_common.py` as the lack of a `test_` prefix was causing the tests not to be run.
* Added missing `_dot_cossim` tests.

* Fix `nchannels_to_rgb` & `Direction` assert

* Moved the `hue_to_rgb` function outside of `nchannels_to_rgb` for JIT support.
* Fixed `nchannels_to_rgb` and `hue_to_rgb` functions.
* Fixed `Direction` loss objective assert.

* Fix `image_cov` & related tests

* Fix conflicts for common -> test_common.py

* Merge updates from optim-wip branch

* Fix test error

* Fix cossim test
…orch#831)

* Add explanations to losses

* Add argument documentation for losses

* Lint fix
…edImage (pytorch#833)

* Add new StackImage parameterization & JIT support for SharedImage

* Added `SimpleTensorParameterization` as a workaround for JIT not supporting `nn.ParameterList`. It also helps `StackImage` support tensor inputs.
* Added JIT support for `SharedImage`.
* Added new parameterization called `StackImage`, that stacks multiple parameterizations (that are can be on different devices) along the batch dimension.

* Fix test version checks

* More tests & new AugmentedImageParameterization base class

* Added `AugmentedImageParameterization` class to use a base for `SharedImage` and `StackImage`.
* Removed `PixelImage`'s 3 channel assert, as there was no reason for limitation.
* Added tests for `InputParameterization`, `ImageParameterization`, & `AugmentedImageParameterization`.

* Add JIT support for SharedImage._interpolate_tensor

* Added JIT support for SharedImage's interpolation operations.
* Unfortunately, JIT support required me to separate SharedImage's bilinear and trilinear resizing into separate functions as Union's of tuples are currently broken. Union support was also a newer addition, so now SharedImage can support older PyTorch versions as well.

* Add dim variable to StackImage

* Added the `dim` variable to `StackImage` so that users can choose what dimension to stack the image parameterizations across.

* Fix test version

* AugmentedImageParameterization -> ImageParameterization

* Remove unused code
* 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 (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
* Fix duplicated target bug

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

* Add ToDo comment for target handling
@ProGamerGov ProGamerGov merged commit 32e4f33 into master-0-new-1 Mar 30, 2025
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.

4 participants