https://github.com/pierreablin/ksddescent
Kernel Stein Discrepancy Descent : a method to sample from unnormalized densities
https://github.com/pierreablin/ksddescent
sampling
Last synced: 11 months ago
JSON representation
Kernel Stein Discrepancy Descent : a method to sample from unnormalized densities
- Host: GitHub
- URL: https://github.com/pierreablin/ksddescent
- Owner: pierreablin
- License: mit
- Created: 2021-04-11T17:27:07.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2024-04-13T19:27:50.000Z (almost 2 years ago)
- Last Synced: 2025-03-31T14:36:33.885Z (about 1 year ago)
- Topics: sampling
- Language: Python
- Homepage:
- Size: 7.2 MB
- Stars: 21
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
Kernel Stein Discrepancy Descent
================================
|GHActions|_ |PyPI|_
.. |GHActions| image:: https://github.com/pierreablin/ksddescent/workflows/unittests/badge.svg?branch=main&event=push
.. _GHActions: https://github.com/pierreablin/ksddescent/actions
.. |PyPI| image:: https://badge.fury.io/py/ksddescent.svg
.. _PyPI: https://badge.fury.io/py/ksddescent
Sampling by optimization of the Kernel Stein Discrepancy
The paper is available at `arxiv.org/abs/2105.09994 `_.
The code uses Pytorch, and a numpy backend is available for svgd.
.. image:: https://pierreablin.github.io/figures/ksd_descent_small.png
:width: 100
:alt: ksd_picture
Install
-------
The code is available on pip::
$ pip install ksddescent
Documentation
-------------
The documentation is at `pierreablin.github.io/ksddescent/ `_.
Example
-------
The main function is `ksdd_lbfgs`, which uses the fast L-BFGS algorithm to converge quickly.
It takes as input the initial position of the particles, and the score function.
For instance, to samples from a Gaussian (where the score is identity), you can use these simple lines of code:
.. code:: python
>>> import torch
>>> from ksddescent import ksdd_lbfgs
>>> n, p = 50, 2
>>> x0 = torch.rand(n, p) # start from uniform distribution
>>> score = lambda x: x # simple score function
>>> x = ksdd_lbfgs(x0, score) # run the algorithm
Reference
---------
If you use this code in your project, please cite::
Anna Korba, Pierre-Cyril Aubin-Frankowski, Simon Majewski, Pierre Ablin
Kernel Stein Discrepancy Descent
International Conference on Machine Learning, 2021
Bug reports
-----------
Use the `github issue tracker `_ to report bugs.