All Projects → amirgholami → Pyhessian

amirgholami / Pyhessian

Licence: mit
PyHessian is a Pytorch library for second-order based analysis and training of Neural Networks

Projects that are alternatives of or similar to Pyhessian

Installations mac ubuntu windows
Installations for Data Science. Anaconda, RStudio, Spark, TensorFlow, AWS (Amazon Web Services).
Stars: ✭ 231 (-0.43%)
Mutual labels:  jupyter-notebook
Mattnet
MAttNet: Modular Attention Network for Referring Expression Comprehension
Stars: ✭ 232 (+0%)
Mutual labels:  jupyter-notebook
Datasets
source{d} datasets ("big code") for source code analysis and machine learning on source code
Stars: ✭ 231 (-0.43%)
Mutual labels:  jupyter-notebook
Introduction To Python
Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991, Python's design philosophy emphasizes code readability with its notable use of significant white space. (This repository contains Python 3 Code)
Stars: ✭ 232 (+0%)
Mutual labels:  jupyter-notebook
Statannot
add statistical annotations (pvalue significance) on an existing boxplot generated by seaborn boxplot
Stars: ✭ 228 (-1.72%)
Mutual labels:  jupyter-notebook
Relevant Search Book
Code and Examples for Relevant Search
Stars: ✭ 231 (-0.43%)
Mutual labels:  jupyter-notebook
Dagmm
My attempt at reproducing the paper Deep Autoencoding Gaussian Mixture Model for Unsupervised Anomaly Detection
Stars: ✭ 231 (-0.43%)
Mutual labels:  jupyter-notebook
Whilemymcmcgentlysamples
my blog
Stars: ✭ 232 (+0%)
Mutual labels:  jupyter-notebook
Pystacknet
Stars: ✭ 232 (+0%)
Mutual labels:  jupyter-notebook
Nn
🧑‍🏫 50! Implementations/tutorials of deep learning papers with side-by-side notes 📝; including transformers (original, xl, switch, feedback, vit, ...), optimizers (adam, adabelief, ...), gans(cyclegan, stylegan2, ...), 🎮 reinforcement learning (ppo, dqn), capsnet, distillation, ... 🧠
Stars: ✭ 5,720 (+2365.52%)
Mutual labels:  jupyter-notebook
Aotodata
朱小五写文章涉及到的数据分析,爬虫,源数据
Stars: ✭ 232 (+0%)
Mutual labels:  jupyter-notebook
Wassdistance
Approximating Wasserstein distances with PyTorch
Stars: ✭ 229 (-1.29%)
Mutual labels:  jupyter-notebook
Mxnet The Straight Dope
An interactive book on deep learning. Much easy, so MXNet. Wow. [Straight Dope is growing up] ---> Much of this content has been incorporated into the new Dive into Deep Learning Book available at https://d2l.ai/.
Stars: ✭ 2,551 (+999.57%)
Mutual labels:  jupyter-notebook
Stylegan2 Face Modificator
Simple Encoder, Generator and Face Modificator with StyleGAN2
Stars: ✭ 232 (+0%)
Mutual labels:  jupyter-notebook
Smt
Surrogate Modeling Toolbox
Stars: ✭ 233 (+0.43%)
Mutual labels:  jupyter-notebook
Imaginary Numbers Are Real
Code To Accompany YouTube Series Imaginary Numbers Are Real
Stars: ✭ 231 (-0.43%)
Mutual labels:  jupyter-notebook
Awesome Pandas
A collection of resources for pandas (Python) and related subjects.
Stars: ✭ 232 (+0%)
Mutual labels:  jupyter-notebook
My tech resources
List of tech resources future me and other Javascript/Ruby/Python/Elixir/Elm developers might find useful
Stars: ✭ 233 (+0.43%)
Mutual labels:  jupyter-notebook
Pandas Highcharts
Beautiful charting of pandas.DataFrame with Highcharts
Stars: ✭ 233 (+0.43%)
Mutual labels:  jupyter-notebook
Tensorflow 101
TensorFlow Tutorials
Stars: ✭ 2,565 (+1005.6%)
Mutual labels:  jupyter-notebook

Block

Block

Introduction

PyHessian is a pytorch library for Hessian based analysis of neural network models. The library enables computing the following metrics:

  • Top Hessian eigenvalues
  • The trace of the Hessian matrix
  • The full Hessian Eigenvalues Spectral Density (ESD)

For more details please see:

Publication List

This project was supported through NSF funding and we are interested in documenting related publications written on or with the help of PyHessian. This will allows us to continue developing the library, and will also be a good summary for related and on going work on second order methods. You can see the current list here. Please contact us if you have a related paper and we would be glad to add it to the list.

Usage

Please first clone the PyHessian library to your local system:

git clone https://github.com/amirgholami/PyHessian.git

Before running the Hessian code, we need a (pre-trained) NN model. Here, we provide a training file to train ResNet20 model on Cifar-10 dataset:

export CUDA_VISIBLE_DEVICES=0; python training.py [--batch-size] [--test-batch-size] [--epochs] [--lr] [--lr-decay] [--lr-decay-epoch] [--seed] [--weight-decay] [--batch-norm] [--residual] [--cuda] [--saving-folder]

optional arguments:
--batch-size                training batch size (default: 128)
--test-batch-size           testing batch size (default:256)
--epochs                    total number of training epochs (default: 180)
--lr                        initial learning rate (default: 0.1)
--lr-decay                  learning rate decay ratio (default: 0.1)
--lr-decay-epoch            epoch for the learning rate decaying (default: 80, 120)
--seed                      used to reproduce the results (default: 1)
--weight-decay              weight decay value (default: 5e-4)
--batch-norm                do we need batch norm in ResNet or not (default: True)
--residual                  do we need residual connection or not (default: True)
--cuda                      do we use gpu or not (default: True)
--saving-folder             saving path of the final checkpoint (default: checkpoints/)

After the model checkpoint is saved, we can run the following code to get the top eigenvalue, trace, and the Eigenvalue Spectral Density of Hessian:

export CUDA_VISIBLE_DEVICES=0; python example_pyhessian_analysis.py [--mini-hessian-batch-size] [--hessian-batch-size] [--seed] [--batch-norm] [--residual] [--cuda] [--resume]

optional arguments:
--mini-hessian-batch-size   mini hessian batch size (default: 200)
--hessian-batch-size        hessian batch size (default:200)
--seed                      used to reproduce the results (default: 1)
--batch-norm                do we need batch norm in ResNet or not (default: True)
--residual                  do we need residual connection or not (default: True)
--cuda                      do we use gpu or not (default: True)
--resume                    resume path of the checkpoint (default: none, must be filled by user)

The output density plot is saved as example.pdf

Citation

PyHessian has been developed as part of the following paper. We appreciate it if you would please cite the following paper if you found the library useful for your work:

  • Z. Yao, A. Gholami, K Keutzer, M. Mahoney. PyHessian: Neural Networks Through the Lens of the Hessian, Spotlight at ICML workshop on Beyond First-Order Optimization Methods in Machine Learning, 2020, PDF.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].