Skip to main content

Hypernetwork library for PyTorch

Project description

Hypernetworks for PyTorch

This package contains utilities that make it easy to work with hypernetworks in PyTorch.

Installation

You can either install the latest package version via

python3 -m pip install hypnettorch

or, you directly install the current sources

python3 -m pip install git+https://github.com/chrhenning/hypnettorch

Installation for developers

If you actively develop the package, it is easiest to install it in development mode, such that all changes that are done to source files are directly visible when you use the package.

Clone the repository to a location of your choice

git clone https://github.com/chrhenning/hypnettorch.git

and move inside the cloned repo

cd ./hypnettorch

Now, you can simply install the package in editable mode, which will ensure that you can easily update the package sources (cf. development mode)

pip3 install --editable . --user

Since the package was installed in editable mode, you can always update the sources simply by pulling the most recent code

git pull

You can uninstall the package at any point by running python3 setup.py develop -u.

Usage

The basic functionalities of the package are quite intuitive and easy to use, e.g.,

import torch
from hypnettorch.mnets import MLP
from hypnettorch.hnets import HMLP
mnet = MLP(n_in=8, n_out=1, no_weights=True) # Create MLP with 8 inputs and 1 output.
hnet = HMLP(mnet.param_shapes) # Create hypernetwork for the above MLP.
weights = hnet.forward(cond_id=0) # Generate the weights of network `mnet`.
inputs = torch.rand(32, 8) # Random inputs.
mnet.forward(inputs, weights=weights) # Compute predictions using the generated weights.

There are several tutorials. Check out the getting started tutorial when working with hypnettorch for the first time.

Documentation

The documentation can be found here.

Note for developers

The documentation can be build using

python3 setup.py build_sphinx

and opened via the file index.html.

Citation

When using this package in your research project, please consider citing one of our papers for which this package has been developed.

@inproceedings{oshg2019hypercl,
title={Continual learning with hypernetworks},
author={Johannes von Oswald and Christian Henning and Jo{\~a}o Sacramento and Benjamin F. Grewe},
booktitle={International Conference on Learning Representations},
year={2020},
url={https://arxiv.org/abs/1906.00695}
}
@inproceedings{ehret2020recurrenthypercl,
  title={Continual Learning in Recurrent Neural Networks},
  author={Benjamin Ehret and Christian Henning and Maria R. Cervera and Alexander Meulemans and Johannes von Oswald and Benjamin F. Grewe},
  booktitle={International Conference on Learning Representations},
  year={2021},
  url={https://arxiv.org/abs/2006.12109}
}
@inproceedings{posterior:replay:2021:henning:cervera,
title={Posterior Meta-Replay for Continual Learning}, 
      author={Christian Henning and Maria R. Cervera and Francesco D'Angelo and Johannes von Oswald and Regina Traber and Benjamin Ehret and Seijin Kobayashi and Benjamin F. Grewe and João Sacramento},
booktitle={Conference on Neural Information Processing Systems},
year={2021},
url={https://arxiv.org/abs/2103.01133}
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hypnettorch-0.0.4.tar.gz (367.0 kB view details)

Uploaded Source

Built Distribution

hypnettorch-0.0.4-py3-none-any.whl (456.9 kB view details)

Uploaded Python 3

File details

Details for the file hypnettorch-0.0.4.tar.gz.

File metadata

  • Download URL: hypnettorch-0.0.4.tar.gz
  • Upload date:
  • Size: 367.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.12

File hashes

Hashes for hypnettorch-0.0.4.tar.gz
Algorithm Hash digest
SHA256 ff46ab52d9ec6e62851b6ac21fccd3277151eda8d69d0b35497d14ef27d368a6
MD5 325bcd70634e5fbdce76164d63b00fe0
BLAKE2b-256 c2b6e5490071c57ddef92a5e063119b5d48eafa588a003f39d17257cc4a7e4e1

See more details on using hashes here.

File details

Details for the file hypnettorch-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: hypnettorch-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 456.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.12

File hashes

Hashes for hypnettorch-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 93c04577b63c01262a31e63aafbb3ce681ed0b41e0d860795b4e6d9529f5018c
MD5 ee84c83927e70d85173a917eeecfb235
BLAKE2b-256 468144ba94976e0bd723420b2b0422951e46938170e7b5be54c4317500250811

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page