SGLD in PyTorch
This package implements SGLD and cSGLD as a PyTorch Optimizer.
Installation
Install from pip as:
pip install torch-sgld
To install the latest directly from source, run
pip install git+https://github.com/activatedgeek/torch-sgld.git
Usage
The general idea is to modify the usual gradient-based update loops
in PyTorch with the SGLD optimizer.
from torch_sgld import SGLD
f = module() ## construct PyTorch nn.Module.
sgld = SGLD(f.parameters(), lr=lr, momentum=.9) ## Add momentum to make it SG-HMC.
sgld_scheduler = ## Optionally add a step-size scheduler.
for _ in range(num_steps):
energy = f()
energy.backward()
sgld.step()
sgld_scheduler.step() ## Optional scheduler step.
cSGLD can be implemented by using a cyclical learning rate schedule.
See the toy_csgld.ipynb notebook for a
complete example.
License
Apache 2.0
Metadata
Release files for torch-sgld 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| torch-sgld-0.1.0.tar.gz | 8.2 kB | Without provenance | Details for torch-sgld-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| torch_sgld-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for torch_sgld-0.1.0-py3-none-any.whl |
Total release size: 17.0 kB
Release files / torch-sgld-0.1.0.tar.gz
| Download URL | torch-sgld-0.1.0.tar.gz |
|---|---|
| Size | 8.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3bea70771e8215f64313c3ec7fbd88cd16e6f7a41cddd246eaffffaf856a02ce
|
|
BLAKE2b-256 checksum How to use checksums |
a9f4d2029ce2535111854d305749f0392ee650beef2401a0aaf817591e5bc21f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Release files / torch_sgld-0.1.0-py3-none-any.whl
| Download URL | torch_sgld-0.1.0-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
566882f7995e08907911dc90965fd7b90062312941099ff1eed1a1d47a7a6396
|
|
BLAKE2b-256 checksum How to use checksums |
27180b0d1191defc8a54ec4dddc56c36f87e8baa35b0f716a09e48235eef6e66
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.11.2
|
Security for torch-sgld 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.