Package containing utilities for implementing RSN2/MANN
Project description
MANN
MANN, which stands for Multitask Artificial Neural Networks, is a Python package which enables creating sparse multitask models compatible with TensorFlow. This package contains custom layers and utilities to facilitate the training and optimization of models using the Reduction of Sub-Network Neuroplasticity (RSN2) training procedure developed by AI Squared, Inc.
Installation
This package is available through PyPi and can be installed via the following command:
pip install mann
To install the current version directly from GitHub without cloning, run the following command:
pip install git+https://github.com/AISquaredInc/mann.git
Alternatively, you can install the package by cloning the repository from GitHub using the following commands:
# clone the repository and cd into it
git clone https://github.com/AISquaredInc/mann
cd mann
# install the package
pip install .
Mac M1 Users
For those with a Mac with the M1 processor, this package can be installed, but the standard version of TensorFlow is not compatible with the M1 SOC. In order to install a compatible version of TensorFlow, please install the Miniforge conda environment, which utilizes the conda-forge channel only. Once you are using Miniforge, using conda to install TensorFlow in that environment should install the correct version. After installing TensorFlow, the command pip install mann
will install the MANN package.
Capabilities
The MANN package includes two subpackages, the mann.utils
package and the mann.layers
package. As the name implies, the mann.utils
package includes utilities which assist in model training. The mann.layers
package includes custom Keras-compatible layers which can be used to train sparse multitask models.
Utils
The mann.utils
subpackage has three main functions: the mask_model
function, the get_custom_objects
function, and the convert_model
function.
In addition to the functions just mentioned, there is also an ActiveSparsification
callback object which enables active sparsification during training rather than solely one-shot sparsification.
mask_model
- The
mask_model
function is central to the RSN2 training procedure and enables masking/pruning a model so a large percentage of the weights are inactive. - Inputs to the
mask_model
function are a TensorFlow model, a percentile in integer form, a method - either one of 'gradients' or 'magnitude', input data, and target data.
- The
get_custom_objects
- The
get_custom_objects
function takes no parameters and returns a dictionary of all custom objects required to load a model trained using this package.
- The
remove_layer_masks
- The
remove_layer_masks
function takes a trained model with masked layers and converts it to a model without masking layers.
- The
Layers
The mann.layers
subpackage contains custom Keras-compatible layers which can be used to train sparse multitask models. The layers contained in this package are as follows:
MaskedDense
- This layer is nearly identical to the Keras Dense layer, but it supports masking and pruning to reduce the number of active weights.
MaskedConv2D
- This layer is nearly identical to the Keras Conv2D layer, but it supports masking and pruning to reduce the number of active weights.
MultiMaskedDense
- This layer supports isolating pathways within the network and dedicating them for individual tasks and performing fully-connected operations on the input data.
MultiMaskedConv2D
- This layer supports isolating pathways within the network and dedicating them for individual tasks and performing convolutional operations on the input data.
MultiDense
- This layer supports multitask inference using a fully-connected architecture and is not designed for training. Once a model is trained with the
MultiMaskedDense
layer, that layer can be converted into this layer for inference by using themann.utils.remove_layer_masks
function.
- This layer supports multitask inference using a fully-connected architecture and is not designed for training. Once a model is trained with the
MultiConv2D
- This layer supports multitask inference using a convolutional architecture and is not designed for training. Once a model is trained with the
MultiMaskedConv2D
layer, that layer can be converted to this layer for inference by using themann.utils.remove_layer_masks
function.
- This layer supports multitask inference using a convolutional architecture and is not designed for training. Once a model is trained with the
SelectorLayer
- This layer selects which of the multiple inputs fed into it is returned as a result. This layer is designed to be used specifically with multitask layers.
SumLayer
- This layer returns the element-wise sum of all of the inputs.
FilterLayer
- This layer can be turned on or off, and indicates whether the single input passed to it should be output or if all zeros should be returned.
MultiMaxPool2D
- This layer implements Max Pool operations on multitask inputs.
Additional Documentation and Training Materials
Additional documentation and training materials will be added to the AI Squared Website as we continue to develop this project and its capabilities.
Feature Roadmap
- Transformers
- We are in the process of adding the Transformer Architecture into this package. Creating these layers will enable the training of multitask compressed models specifically for Natural Language Processing (NLP). Stay tuned!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mann-0.2.0.dev1.tar.gz
.
File metadata
- Download URL: mann-0.2.0.dev1.tar.gz
- Upload date:
- Size: 17.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/0.0.0 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f02e1d7a3b0cb324ffb94f310805f1b4f777a3039dc63bd03e65d7da11927861 |
|
MD5 | bf850d22afd2bf6ad3282896dc2ae39b |
|
BLAKE2b-256 | d4d5c345485bf155436dcf1b4d676b51be351617028e071a5862cb3c982ed8c9 |
File details
Details for the file mann-0.2.0.dev1-py3-none-any.whl
.
File metadata
- Download URL: mann-0.2.0.dev1-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/0.0.0 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89bef2c4efb70866eb7d6008b8492952f924fc737949982484553e192b300cfe |
|
MD5 | ee19305817260c86ed07a9bb878c2c4f |
|
BLAKE2b-256 | 7fcffb5f5751c3d00423eaafec3394977bfe22038677065a256cdbeebdfe5f83 |