{"id":13737004,"url":"https://github.com/moskomule/anatome","last_synced_at":"2025-04-14T22:26:14.293Z","repository":{"id":45970611,"uuid":"283541182","full_name":"moskomule/anatome","owner":"moskomule","description":"Ἀνατομή is a PyTorch library to analyze representation of neural networks","archived":false,"fork":false,"pushed_at":"2023-11-17T20:10:10.000Z","size":308,"stargazers_count":62,"open_issues_count":4,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-28T10:47:18.984Z","etag":null,"topics":["neural-networks","pytorch","pytorch-library","representation-learning"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/moskomule.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2020-07-29T15:53:22.000Z","updated_at":"2024-10-24T08:56:59.000Z","dependencies_parsed_at":"2024-01-11T13:19:38.734Z","dependency_job_id":null,"html_url":"https://github.com/moskomule/anatome","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moskomule%2Fanatome","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moskomule%2Fanatome/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moskomule%2Fanatome/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/moskomule%2Fanatome/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/moskomule","download_url":"https://codeload.github.com/moskomule/anatome/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248970464,"owners_count":21191437,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["neural-networks","pytorch","pytorch-library","representation-learning"],"created_at":"2024-08-03T03:01:33.402Z","updated_at":"2025-04-14T22:26:14.276Z","avatar_url":"https://github.com/moskomule.png","language":"Jupyter Notebook","funding_links":[],"categories":["Jupyter Notebook"],"sub_categories":[],"readme":"# anatome ![](https://github.com/moskomule/anatome/workflows/pytest/badge.svg)\n\nἈνατομή is a PyTorch library to analyze internal representation of neural networks\n\nThis project is under active development and the codebase is subject to change.\n\n**v0.0.5 introduces significant changes to `distance`.**\n\n## Installation\n\n`anatome` requires\n\n```\nPython\u003e=3.9.0\nPyTorch\u003e=1.10\ntorchvision\u003e=0.11\n```\n\nAfter the installation of PyTorch, install `anatome` as follows:\n\n```\npip install -U git+https://github.com/moskomule/anatome\n```\n\n## Available Tools\n\n### Representation Similarity\n\nTo measure the similarity of learned representation, `anatome.SimilarityHook` is a useful tool. Currently, the following\nmethods are implemented.\n\n- [Raghu et al. NIPS2017 SVCCA](https://papers.nips.cc/paper/7188-svcca-singular-vector-canonical-correlation-analysis-for-deep-learning-dynamics-and-interpretability)\n- [Marcos et al. NeurIPS2018 PWCCA](https://papers.nips.cc/paper/7815-insights-on-representational-similarity-in-neural-networks-with-canonical-correlation)\n- [Kornblith et al. ICML2019 Linear CKA](http://proceedings.mlr.press/v97/kornblith19a.html)\n- [Ding et al. arXiv Orthogonal Procrustes distance](https://arxiv.org/abs/2108.01661)\n\n```python\nimport torch\nfrom torchvision.models import resnet18\nfrom anatome import Distance\n\nrandom_model = resnet18()\nlearned_model = resnet18(pretrained=True)\ndistance = Distance(random_model, learned_model, method='pwcca')\nwith torch.no_grad():\n    distance.forward(torch.randn(256, 3, 224, 224))\n\n# resize if necessary by specifying `size`\ndistance.between(\"layer3.0.conv1\", \"layer3.0.conv1\", size=8)\n```\n\n### Loss Landscape Visualization\n\n- [Li et al. NeurIPS2018](https://papers.nips.cc/paper/7875-visualizing-the-loss-landscape-of-neural-nets)\n\n```python\nfrom torch.nn import functional as F\nfrom torchvision.models import resnet18\nfrom anatome import landscape2d\n\nx, y, z = landscape2d(resnet18(),\n                      data,\n                      F.cross_entropy,\n                      x_range=(-1, 1),\n                      y_range=(-1, 1),\n                      step_size=0.1)\nimshow(z)\n```\n\n![](assets/landscape2d.svg)\n![](assets/landscape3d.svg)\n\n### Fourier Analysis\n\n- Yin et al. NeurIPS 2019 etc.,\n\n```python\nfrom torch.nn import functional as F\nfrom torchvision.models import resnet18\nfrom anatome import fourier_map\n\nmap = fourier_map(resnet18(),\n                  data,\n                  F.cross_entropy,\n                  norm=4)\nimshow(map)\n```\n\n![](assets/fourier.svg)\n\n## Citation\n\nIf you use this implementation in your research, please cite as:\n\n```\n@software{hataya2020anatome,\n    author={Ryuichiro Hataya},\n    title={anatome, a PyTorch library to analyze internal representation of neural networks},\n    url={https://github.com/moskomule/anatome},\n    year={2020}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoskomule%2Fanatome","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmoskomule%2Fanatome","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmoskomule%2Fanatome/lists"}