summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--python-ultimate-anatome.spec540
-rw-r--r--sources1
3 files changed, 542 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index e69de29..dbb82c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/ultimate-anatome-0.1.1.tar.gz
diff --git a/python-ultimate-anatome.spec b/python-ultimate-anatome.spec
new file mode 100644
index 0000000..78c990a
--- /dev/null
+++ b/python-ultimate-anatome.spec
@@ -0,0 +1,540 @@
+%global _empty_manifest_terminate_build 0
+Name: python-ultimate-anatome
+Version: 0.1.1
+Release: 1
+Summary: Ἀνατομή (Anatome) is a PyTorch library to analyze representation of neural networks
+License: MIT
+URL: https://github.com/brando90/ultimate-anatome
+Source0: https://mirrors.nju.edu.cn/pypi/web/packages/d7/83/41e194e19878eea5cbd9647c5832fb94499307895365de0b2fba5e839f73/ultimate-anatome-0.1.1.tar.gz
+BuildArch: noarch
+
+Requires: python3-torch
+Requires: python3-torchvision
+Requires: python3-tqdm
+
+%description
+# anatome ![](https://github.com/moskomule/anatome/workflows/pytest/badge.svg)
+
+Ἀνατομή is a PyTorch library to analyze internal representation of neural networks
+
+This project is under active development and the codebase is subject to change.
+
+Note the name of the pypi package is `ultimate-anatome` but the python import is done with
+the original name `import anatome`.
+Test via:
+```angular2html
+python -c "import anatome.my_utils as my_utils;my_utils.hello()"
+python -c "import anatome.my_utils as my_utils;my_utils.my_anatome_test()"
+```
+
+Credit to original library: https://github.com/moskomule/anatome and consider citing both of us! Citation at the end of readme.
+
+## Installation
+
+If you are going to use a gpu the do this first before continuing
+(or check the offical website: https://pytorch.org/get-started/locally/):
+```angular2html
+pip3 install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
+```
+Otherwise, just doing the follwoing should work.
+```
+pip install ultimate-anatome
+```
+
+## Manual installation [for Development]
+
+To use code first get the code from this repo (e.g. fork it on github):
+
+```
+git clone git@github.com:brando90/ultimate-anatome.git
+```
+
+Then install it in development mode in your python env with python >=3.9.
+E.g. create your env with conda:
+
+```
+conda create -n ultimate_anatome_env python=3.9
+conda activate ultimate_anatome_env
+```
+
+Then install code in edibable mode and all it's depedencies with pip in the currently activated conda environment:
+
+```
+pip install -e ~/ultimate-anatome
+```
+
+## Available Tools
+
+### Representation Similarity
+
+To measure the similarity of learned representation, `anatome.SimilarityHook` is a useful tool. Currently, the following
+methods are implemented.
+
+- [Raghu et al. NIPS2017 SVCCA](https://papers.nips.cc/paper/7188-svcca-singular-vector-canonical-correlation-analysis-for-deep-learning-dynamics-and-interpretability)
+- [Marcos et al. NeurIPS2018 PWCCA](https://papers.nips.cc/paper/7815-insights-on-representational-similarity-in-neural-networks-with-canonical-correlation)
+- [Kornblith et al. ICML2019 Linear CKA](http://proceedings.mlr.press/v97/kornblith19a.html)
+- [Ding et al. arXiv Orthogonal Procrustes distance](https://arxiv.org/abs/2108.01661)
+
+```python
+import torch
+from torchvision.models import resnet18
+from anatome import DistanceHook
+from anatome.my_utils import remove_hook
+
+model = resnet18()
+hook1 = DistanceHook(model, "layer3.0.conv1")
+hook2 = DistanceHook(model, "layer3.0.conv2")
+model.eval()
+with torch.no_grad():
+ model(torch.randn(128, 3, 224, 224))
+# downsampling to (size, size) may be helpful
+hook1.distance(hook2, size=8)
+hook1.clear()
+hook2.clear()
+remove_hook(model, hook1)
+remove_hook(model, hook2)
+```
+
+or to test do:
+```python
+from anatome.my_utils import my_anatome_test
+my_anatome_test()
+```
+
+### Loss Landscape Visualization
+
+- [Li et al. NeurIPS2018](https://papers.nips.cc/paper/7875-visualizing-the-loss-landscape-of-neural-nets)
+
+```python
+from anatome import landscape2d
+
+x, y, z = landscape2d(resnet18(),
+ data,
+ F.cross_entropy,
+ x_range=(-1, 1),
+ y_range=(-1, 1),
+ step_size=0.1)
+imshow(z)
+```
+
+![](assets/landscape2d.svg)
+![](assets/landscape3d.svg)
+
+### Fourier Analysis
+
+- Yin et al. NeurIPS 2019 etc.,
+
+```python
+from anatome import fourier_map
+
+map = fourier_map(resnet18(),
+ data,
+ F.cross_entropy,
+ norm=4)
+imshow(map)
+```
+
+![](assets/fourier.svg)
+
+## Citation
+
+If you use this implementation in your research, please conser citing my version of anatome:
+```
+@software{miranda2021ultimate_anatome,
+ author={Brando Miranda},
+ title={Ultimate Anatome, the ultimate PyTorch library to analyze internal representation of neural networks},
+ url={https://github.com/brando90/ultimate-anatome},
+ year={2021}
+}
+```
+and the original version:
+
+```
+@software{hataya2020anatome,
+ author={Ryuichiro Hataya},
+ title={anatome, a PyTorch library to analyze internal representation of neural networks},
+ url={https://github.com/moskomule/anatome},
+ year={2020}
+}
+```
+
+
+# Related libraries:
+
+- The original anatome of course https://github.com/moskomule/anatome
+- https://github.com/AntixK/PyTorch-Model-Compare From the developers "A tiny package to compare two neural networks in PyTorch. There are many ways to compare two neural networks, but one robust and scalable way is using the Centered Kernel Alignment (CKA) metric, where the features of the networks are compared."
+- Captum is trying to add support. Check it out here: https://github.com/pytorch/captum/issues/572#issuecomment-957306989
+- The original svcca tutorials by Maithra et al https://github.com/google/svcca/tree/master/tutorials
+- if you know more create a pull request and add it here!
+
+
+
+
+%package -n python3-ultimate-anatome
+Summary: Ἀνατομή (Anatome) is a PyTorch library to analyze representation of neural networks
+Provides: python-ultimate-anatome
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-ultimate-anatome
+# anatome ![](https://github.com/moskomule/anatome/workflows/pytest/badge.svg)
+
+Ἀνατομή is a PyTorch library to analyze internal representation of neural networks
+
+This project is under active development and the codebase is subject to change.
+
+Note the name of the pypi package is `ultimate-anatome` but the python import is done with
+the original name `import anatome`.
+Test via:
+```angular2html
+python -c "import anatome.my_utils as my_utils;my_utils.hello()"
+python -c "import anatome.my_utils as my_utils;my_utils.my_anatome_test()"
+```
+
+Credit to original library: https://github.com/moskomule/anatome and consider citing both of us! Citation at the end of readme.
+
+## Installation
+
+If you are going to use a gpu the do this first before continuing
+(or check the offical website: https://pytorch.org/get-started/locally/):
+```angular2html
+pip3 install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
+```
+Otherwise, just doing the follwoing should work.
+```
+pip install ultimate-anatome
+```
+
+## Manual installation [for Development]
+
+To use code first get the code from this repo (e.g. fork it on github):
+
+```
+git clone git@github.com:brando90/ultimate-anatome.git
+```
+
+Then install it in development mode in your python env with python >=3.9.
+E.g. create your env with conda:
+
+```
+conda create -n ultimate_anatome_env python=3.9
+conda activate ultimate_anatome_env
+```
+
+Then install code in edibable mode and all it's depedencies with pip in the currently activated conda environment:
+
+```
+pip install -e ~/ultimate-anatome
+```
+
+## Available Tools
+
+### Representation Similarity
+
+To measure the similarity of learned representation, `anatome.SimilarityHook` is a useful tool. Currently, the following
+methods are implemented.
+
+- [Raghu et al. NIPS2017 SVCCA](https://papers.nips.cc/paper/7188-svcca-singular-vector-canonical-correlation-analysis-for-deep-learning-dynamics-and-interpretability)
+- [Marcos et al. NeurIPS2018 PWCCA](https://papers.nips.cc/paper/7815-insights-on-representational-similarity-in-neural-networks-with-canonical-correlation)
+- [Kornblith et al. ICML2019 Linear CKA](http://proceedings.mlr.press/v97/kornblith19a.html)
+- [Ding et al. arXiv Orthogonal Procrustes distance](https://arxiv.org/abs/2108.01661)
+
+```python
+import torch
+from torchvision.models import resnet18
+from anatome import DistanceHook
+from anatome.my_utils import remove_hook
+
+model = resnet18()
+hook1 = DistanceHook(model, "layer3.0.conv1")
+hook2 = DistanceHook(model, "layer3.0.conv2")
+model.eval()
+with torch.no_grad():
+ model(torch.randn(128, 3, 224, 224))
+# downsampling to (size, size) may be helpful
+hook1.distance(hook2, size=8)
+hook1.clear()
+hook2.clear()
+remove_hook(model, hook1)
+remove_hook(model, hook2)
+```
+
+or to test do:
+```python
+from anatome.my_utils import my_anatome_test
+my_anatome_test()
+```
+
+### Loss Landscape Visualization
+
+- [Li et al. NeurIPS2018](https://papers.nips.cc/paper/7875-visualizing-the-loss-landscape-of-neural-nets)
+
+```python
+from anatome import landscape2d
+
+x, y, z = landscape2d(resnet18(),
+ data,
+ F.cross_entropy,
+ x_range=(-1, 1),
+ y_range=(-1, 1),
+ step_size=0.1)
+imshow(z)
+```
+
+![](assets/landscape2d.svg)
+![](assets/landscape3d.svg)
+
+### Fourier Analysis
+
+- Yin et al. NeurIPS 2019 etc.,
+
+```python
+from anatome import fourier_map
+
+map = fourier_map(resnet18(),
+ data,
+ F.cross_entropy,
+ norm=4)
+imshow(map)
+```
+
+![](assets/fourier.svg)
+
+## Citation
+
+If you use this implementation in your research, please conser citing my version of anatome:
+```
+@software{miranda2021ultimate_anatome,
+ author={Brando Miranda},
+ title={Ultimate Anatome, the ultimate PyTorch library to analyze internal representation of neural networks},
+ url={https://github.com/brando90/ultimate-anatome},
+ year={2021}
+}
+```
+and the original version:
+
+```
+@software{hataya2020anatome,
+ author={Ryuichiro Hataya},
+ title={anatome, a PyTorch library to analyze internal representation of neural networks},
+ url={https://github.com/moskomule/anatome},
+ year={2020}
+}
+```
+
+
+# Related libraries:
+
+- The original anatome of course https://github.com/moskomule/anatome
+- https://github.com/AntixK/PyTorch-Model-Compare From the developers "A tiny package to compare two neural networks in PyTorch. There are many ways to compare two neural networks, but one robust and scalable way is using the Centered Kernel Alignment (CKA) metric, where the features of the networks are compared."
+- Captum is trying to add support. Check it out here: https://github.com/pytorch/captum/issues/572#issuecomment-957306989
+- The original svcca tutorials by Maithra et al https://github.com/google/svcca/tree/master/tutorials
+- if you know more create a pull request and add it here!
+
+
+
+
+%package help
+Summary: Development documents and examples for ultimate-anatome
+Provides: python3-ultimate-anatome-doc
+%description help
+# anatome ![](https://github.com/moskomule/anatome/workflows/pytest/badge.svg)
+
+Ἀνατομή is a PyTorch library to analyze internal representation of neural networks
+
+This project is under active development and the codebase is subject to change.
+
+Note the name of the pypi package is `ultimate-anatome` but the python import is done with
+the original name `import anatome`.
+Test via:
+```angular2html
+python -c "import anatome.my_utils as my_utils;my_utils.hello()"
+python -c "import anatome.my_utils as my_utils;my_utils.my_anatome_test()"
+```
+
+Credit to original library: https://github.com/moskomule/anatome and consider citing both of us! Citation at the end of readme.
+
+## Installation
+
+If you are going to use a gpu the do this first before continuing
+(or check the offical website: https://pytorch.org/get-started/locally/):
+```angular2html
+pip3 install torch==1.9.1+cu111 torchvision==0.10.1+cu111 torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html
+```
+Otherwise, just doing the follwoing should work.
+```
+pip install ultimate-anatome
+```
+
+## Manual installation [for Development]
+
+To use code first get the code from this repo (e.g. fork it on github):
+
+```
+git clone git@github.com:brando90/ultimate-anatome.git
+```
+
+Then install it in development mode in your python env with python >=3.9.
+E.g. create your env with conda:
+
+```
+conda create -n ultimate_anatome_env python=3.9
+conda activate ultimate_anatome_env
+```
+
+Then install code in edibable mode and all it's depedencies with pip in the currently activated conda environment:
+
+```
+pip install -e ~/ultimate-anatome
+```
+
+## Available Tools
+
+### Representation Similarity
+
+To measure the similarity of learned representation, `anatome.SimilarityHook` is a useful tool. Currently, the following
+methods are implemented.
+
+- [Raghu et al. NIPS2017 SVCCA](https://papers.nips.cc/paper/7188-svcca-singular-vector-canonical-correlation-analysis-for-deep-learning-dynamics-and-interpretability)
+- [Marcos et al. NeurIPS2018 PWCCA](https://papers.nips.cc/paper/7815-insights-on-representational-similarity-in-neural-networks-with-canonical-correlation)
+- [Kornblith et al. ICML2019 Linear CKA](http://proceedings.mlr.press/v97/kornblith19a.html)
+- [Ding et al. arXiv Orthogonal Procrustes distance](https://arxiv.org/abs/2108.01661)
+
+```python
+import torch
+from torchvision.models import resnet18
+from anatome import DistanceHook
+from anatome.my_utils import remove_hook
+
+model = resnet18()
+hook1 = DistanceHook(model, "layer3.0.conv1")
+hook2 = DistanceHook(model, "layer3.0.conv2")
+model.eval()
+with torch.no_grad():
+ model(torch.randn(128, 3, 224, 224))
+# downsampling to (size, size) may be helpful
+hook1.distance(hook2, size=8)
+hook1.clear()
+hook2.clear()
+remove_hook(model, hook1)
+remove_hook(model, hook2)
+```
+
+or to test do:
+```python
+from anatome.my_utils import my_anatome_test
+my_anatome_test()
+```
+
+### Loss Landscape Visualization
+
+- [Li et al. NeurIPS2018](https://papers.nips.cc/paper/7875-visualizing-the-loss-landscape-of-neural-nets)
+
+```python
+from anatome import landscape2d
+
+x, y, z = landscape2d(resnet18(),
+ data,
+ F.cross_entropy,
+ x_range=(-1, 1),
+ y_range=(-1, 1),
+ step_size=0.1)
+imshow(z)
+```
+
+![](assets/landscape2d.svg)
+![](assets/landscape3d.svg)
+
+### Fourier Analysis
+
+- Yin et al. NeurIPS 2019 etc.,
+
+```python
+from anatome import fourier_map
+
+map = fourier_map(resnet18(),
+ data,
+ F.cross_entropy,
+ norm=4)
+imshow(map)
+```
+
+![](assets/fourier.svg)
+
+## Citation
+
+If you use this implementation in your research, please conser citing my version of anatome:
+```
+@software{miranda2021ultimate_anatome,
+ author={Brando Miranda},
+ title={Ultimate Anatome, the ultimate PyTorch library to analyze internal representation of neural networks},
+ url={https://github.com/brando90/ultimate-anatome},
+ year={2021}
+}
+```
+and the original version:
+
+```
+@software{hataya2020anatome,
+ author={Ryuichiro Hataya},
+ title={anatome, a PyTorch library to analyze internal representation of neural networks},
+ url={https://github.com/moskomule/anatome},
+ year={2020}
+}
+```
+
+
+# Related libraries:
+
+- The original anatome of course https://github.com/moskomule/anatome
+- https://github.com/AntixK/PyTorch-Model-Compare From the developers "A tiny package to compare two neural networks in PyTorch. There are many ways to compare two neural networks, but one robust and scalable way is using the Centered Kernel Alignment (CKA) metric, where the features of the networks are compared."
+- Captum is trying to add support. Check it out here: https://github.com/pytorch/captum/issues/572#issuecomment-957306989
+- The original svcca tutorials by Maithra et al https://github.com/google/svcca/tree/master/tutorials
+- if you know more create a pull request and add it here!
+
+
+
+
+%prep
+%autosetup -n ultimate-anatome-0.1.1
+
+%build
+%py3_build
+
+%install
+%py3_install
+install -d -m755 %{buildroot}/%{_pkgdocdir}
+if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
+if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
+if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
+if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
+pushd %{buildroot}
+if [ -d usr/lib ]; then
+ find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/lib64 ]; then
+ find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/bin ]; then
+ find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+if [ -d usr/sbin ]; then
+ find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
+fi
+touch doclist.lst
+if [ -d usr/share/man ]; then
+ find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
+fi
+popd
+mv %{buildroot}/filelist.lst .
+mv %{buildroot}/doclist.lst .
+
+%files -n python3-ultimate-anatome -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Mon May 15 2023 Python_Bot <Python_Bot@openeuler.org> - 0.1.1-1
+- Package Spec generated
diff --git a/sources b/sources
new file mode 100644
index 0000000..fe14ac0
--- /dev/null
+++ b/sources
@@ -0,0 +1 @@
+ccb3acd3c08657f90d0ac98928632209 ultimate-anatome-0.1.1.tar.gz