A PyTorch library to analyze representation of neural networks
 
				anatome
Ἀνατομή is a PyTorch library to analyze internal representation of neural networks
This project is under active development and the codebase is subject to change.
Installation
anatome requires
Python>=3.9.0
PyTorch>=1.9.0
torchvision>=0.10.0
After the installation of PyTorch, install anatome as follows:
pip install -U git+https://github.com/moskomule/anatome
Representation Similarity
To measure the similarity of learned representation, anatome.SimilarityHook is a useful tool. Currently, the following
methods are implemented.
from anatome import SimilarityHook
model = resnet18()
hook1 = SimilarityHook(model, "layer3.0.conv1")
hook2 = SimilarityHook(model, "layer3.0.conv2")
model.eval()
with torch.no_grad():
    model(data[0])
# downsampling to (size, size) may be helpful
hook1.distance(hook2, size=8)
Loss Landscape Visualization
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)