Skip to main content

Bayesian Neural Network Pruning

License

Description:

BPrune is developed to perform inference and pruning of Bayesian Neural Networks(BNN) models developed with Tensorflow and Tensorflow Probability. The BNN's supported by the package are one which uses mean field approximation principle of VI i.e uses gaussian to define the priors on the weights. Currently, the pruning threshold is based on the signal to noise ratio threshold.

Features:

  1. Library for performing inference for trained Bayesian Neural Network (BNN).
  2. Library for performing pruning trained Bayesian Neural Network(BNN).
  3. Supports Tensorflow and Tensorflow_probability based Bayesian Neural Network model architecture.
  4. Independent to the BNN's learning task, support BNN models for classification & regression.
  5. Capabilities of handling BNN's which are trained with distributed training libraries such as Horovod.

Installation Instructions:

  • Before installation ensure that you have a working Tensorflow and Tensorflow probability environment.
python3 install -r requirements.txt
python3 install setup.py 

If you are using a pip installation, simply do

python3 -m pip install BPrune
  • For development of the package following command can be used after git clone.
python3 setup.py develop

Quick Start Guide

  • Before running the model for inference or for pruning ensure that at the end of the training script details about the layer names and operations in the graph are written as text files.

  • To achieve this user can use the utility provided with BPrune named as Graph_Info_Writer.

  • The usage of the utility is described as follows:

    import numpy as np
    import tensorflow as tf
    :
    import bprune.src.utils as UT
    
    #
    # All the code for training the BNN
    ...
    ..
    ..
    
    # This path will be used as model_dir path in the argument when running BNN for inference
    case_dir = path/to/the/casefolder
    
    UT.Graph_Info_Writer(case_dir)
    
  • For successful run of BPrune following files ('LayerNames.txt', 'Ops_name_BNN.txt') must be present in the case directory. The above described procedure will ensure these files are written at the end of the BNN training procedure.

  • Once the required text files are written at the end of training, BPrune can be used. The example use case can be found in example folder with the package.

  • The runtime arguments to a BPrune code can be provide using command-line or can be specified using a text file each line stating the argument. example:

    python Prune_BNN_MNIST_Model.py @ArgFilePrune.txt
    

Limitations/TODO's:

  • Only support models trained using tensorflow placeholders for feeding data to the graph.
  • Pruning Algorithm for models using other than Mean Field approximation functions for Variational Inference.
  • Unit-Test for the functionalities.

Cite:

  • Bibtex Format(Arxiv):
     @article{sharma2020bayesian,
     title={Bayesian Neural Networks at Scale: A Performance Analysis and Pruning Study},
     author={Sharma, Himanshu and Jennings, Elise},
     journal={arXiv preprint arXiv:2005.11619},
     year={2020}}
    
  • MLA Format (Arxiv):
      Sharma, Himanshu, and Elise Jennings. "Bayesian Neural Networks at Scale: A Performance Analysis and Pruning Study." arXiv preprint arXiv:2005.11619 (2020).
    

Contact:

Acknowledgement:

This research used resources of the Argonne Leadership Computing Facility, which is a DOE Office of Science User Facility supported under Contract DE-AC02-06CH11357. This research was funded in part and used resources of the Argonne Leadership Computing Facility, which is a DOE Office of Science User Facility supported under Contract DE-AC02-06CH11357. This paper describes objective technical results and analysis. Any subjective views or opinions that might be expressed in the paper do not necessarily represent the views of the U.S. DOE or the United States Government. Declaration of Interests - None.

Release files for BPrune 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for BPrune 0.0.1
File Size Uploaded
BPrune-0.0.1.tar.gz 12.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for BPrune 0.0.1
File Interpreter ABI Platform
BPrune-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.7 kB

Release files / BPrune-0.0.1.tar.gz

Download URL BPrune-0.0.1.tar.gz
Size 12.6 kB
Tags Source
SHA-256 checksum
How to use checksums
3b9fcff2a7eb983c748a3f6e12e9cbcfd8092aa475916c9180903f029ee0d6a9
BLAKE2b-256 checksum
How to use checksums
16452127d78fc699123802986e7cea6bb96a48da9330af0bdb33393eea3ae161
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.6

Release files / BPrune-0.0.1-py3-none-any.whl

Download URL BPrune-0.0.1-py3-none-any.whl
Size 15.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
202512dc9cf8fd40f454041b5bbe9e9bd9199f5b5aeed1df6740149c6c058122
BLAKE2b-256 checksum
How to use checksums
e78b71580645f5ad17c67ff15c7c668cd055ab420d467cd53160e2b288b93b3d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/49.1.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.7.6

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page