Skip to main content

A pytorch extension providing the Bregman optimizers

Project description

A pytorch extension providing Bregman-based optimizers

  • Free software: BSD 3-Clause License

Installation

The package can be install from PyPI using:

pip install bregman-learning

Usage

The library provides 2 Bregman-based optimizers, several regularizers for these optimizers, and functions for pre- and postprocessing the networks.

The Bregman-based optimizers provides are LinBreg and AdaBreg. Their usage is similar to the usage of Adam and SGD, their non-Bregman counterparts. Instead of:

from torch.optim import Adam

...

optimizer = Adam(model.parameters(), lr=learning_rate)

the optimizers are created using:

from bregman import AdaBreg, L1

...

optimizer = AdaBreg(
    model.parameters(),
    reg=L1(rc=regularization_constant),
    lr=learning_rate
)

where the L1 regularizer can be interchanged with any regularizer in the library.

For the best results when using sparsity-promoting regularizers, the networks have to pre- and postprocessed accordingly. For the L12 regularizer, this can be done using:

from bregman import sparsify

...

sparsify(model, density_level=0.2)

and:

from bregman import simplify

...

pruned_model = simplify(model)

Citing

If you use this code, please use the citation information in the CITATION.cff file or click the cite this repository button in the sitebar.

Changelog

0.0.0 (2022-06-17)

  • First release on PyPI.

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

bregman_learning-0.0.0.tar.gz (23.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bregman_learning-0.0.0-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file bregman_learning-0.0.0.tar.gz.

File metadata

  • Download URL: bregman_learning-0.0.0.tar.gz
  • Upload date:
  • Size: 23.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.8

File hashes

Hashes for bregman_learning-0.0.0.tar.gz
Algorithm Hash digest
SHA256 47f2e2bae4a985c1cd4e12c4c058cbac90c70746c74647843ef247b1998ccbb1
MD5 7b77ba71d4261fab481b94b285e1c72f
BLAKE2b-256 b7de062ddd3dc47b6f7c28ff92dbeef07529af8c1ab3ee466deebe9447be059b

See more details on using hashes here.

File details

Details for the file bregman_learning-0.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bregman_learning-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 da3d30b3650b35367493c211f279801a49bd932288b59f91508955c235497177
MD5 53b11a92a34f5a2d6cb8508a456b92b0
BLAKE2b-256 2841c5f3fcb72129a9c4e2ca57911fa06cb189e7e606e43968b6087b14a3afea

See more details on using hashes here.

Supported by

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