Metadata-Version: 2.4
Name: pylandscape
Version: 0.1.3a1
Summary: Python package to explore the loss landscape of Machine Learning models
License: MIT
License-File: LICENSE.txt
Author: Tommaso Baldi
Requires-Python: >=3.11,<3.13
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Dist: brevitas (>=0.12.1,<0.13.0)
Requires-Dist: ipykernel (>=7.2.0,<8.0.0)
Requires-Dist: numpy
Requires-Dist: pyhessian
Requires-Dist: pytest (>=9.0.2,<10.0.0)
Requires-Dist: scipy (>=1.17.1,<2.0.0)
Requires-Dist: torch (>=2.10,<3.0)
Requires-Dist: torchvision (>=0.25.0,<0.26.0)
Requires-Dist: tqdm
Project-URL: Homepage, https://github.com/balditommaso/PyLandscape
Project-URL: Repository, https://github.com/balditommaso/PyLandscape
Description-Content-Type: text/markdown

# PyLandscape

## Introduction

`pylandscape` is a Pytorch library for loss landscape analysis of neural networks. The library enables computing the following metrics:

- [CKA similarity](https://arxiv.org/pdf/2010.15327)
- [Hessian metrics](https://arxiv.org/pdf/1912.07145)
- [Mode connectivity](https://arxiv.org/pdf/1802.10026)
- [Loss surface](https://arxiv.org/pdf/1712.09913)

*NOTE*: All the functionalities relative to the computation of the Hessian metrics have been embedded via [PyHessian](https://github.com/amirgholami/PyHessian). If your interested in learning more about how these metrics are computed have a look to their Repository.

## Usage

### Install from Pip

You can install the library from pip:

```
pip install pylandscape
```
<!-- 
### Install from source

You can also compile the library from source

```
git clone https://github.com/balditommaso/PyLandscape.git
pip install -r requirements.txt
```

### Download the HGCAL dataset

Hide for double blinded peer reviews.


### Download the Fusion dataset

Hide for double blinded peer reviews.

### Train the models

1. Train full precision (FP32) version of the model:

```
. scripts/train.sh \
    --config ./config/econ/baseline.yml \
    --bs 1024 \
    --lr 0.0015625 \
    --device_id 0 \
    --num_test 3 \
    --full_precision
```

2. Fine tune the models with QAT:

```
. scripts/train.sh \
    --config ./config/large_econ/baseline_gaussian.yml \
    --bs 1024 \
    --lr 0.0015625 \
    --device_id 0 \
    --num_test 3 \
    --pretrained
```

3. Test the model both metrics and benchmarks
```
. scripts/test.sh \
    --config ./config/econ/baseline.yml \
    --bs 1024 \
    --lr 0.0015625 \
    --device_id 0 \
    --max_processes 3 \
    --num_models 3
``` -->


