-
Notifications
You must be signed in to change notification settings - Fork 230
Update variational inference interface to match [email protected]
#2699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Red-Portal
wants to merge
37
commits into
breaking
Choose a base branch
from
bump_advancedvi_0.5
base: breaking
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 36 commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
ea69430
update vi interface to match [email protected]
Red-Portal 86ee6dd
revert unintended commit of `runtests.jl`
Red-Portal 3e30e04
Merge branch 'breaking' of github.com:TuringLang/Turing.jl into bump_…
Red-Portal d870045
update docs for `vi`
Red-Portal 2d928e0
add history entry for `[email protected]`
Red-Portal 5211b37
remove export for removed symbol
Red-Portal f0d615d
fix formatting
Red-Portal 1b2351f
fix formatting
Red-Portal 2be31b4
tidy tests advi
Red-Portal e48ae42
fix rename file `advi.jl` to `vi.jl` to reflect naming changes
Red-Portal 44f7762
fix docs
Red-Portal fd0e928
fix HISTORY.md
Red-Portal 77276bd
fix HISTORY.md
Red-Portal cb1620c
Merge branch 'main' of github.com:TuringLang/Turing.jl into bump_adva…
Red-Portal e70ddb4
update history
Red-Portal 115802d
Merge branch 'bump_advancedvi_0.5' of github.com:TuringLang/Turing.jl…
Red-Portal cdc8b2f
Update README.md for clarity and formatting
yebai 32e70d6
Add linear regression model example to README
yebai 19bf7d6
Add dark/light mode logo support (#2714)
shravanngoswamii 25b5087
Merge branch 'main' of github.com:TuringLang/Turing.jl into bump_adva…
Red-Portal 4c02f7b
bump AdvancedVI version
Red-Portal 6518b82
add exports new algorithms, modify `vi` to operate in unconstrained
Red-Portal 5bd6978
Merge branch 'breaking' of github.com:TuringLang/Turing.jl into bump_…
Red-Portal 874a0b2
add clarification on initializing unconstrained algorithms
Red-Portal e021eb7
update api
Red-Portal eec7ef2
run formatter
Red-Portal b6d8202
run formatter
Red-Portal b900ab4
run formatter
Red-Portal e71b07b
run formatter
Red-Portal c08de12
run formatter
Red-Portal ae80f1e
run formatter
Red-Portal 73bd309
run formatter
Red-Portal eaac4c3
run formatter
Red-Portal 757ebb4
revert changes to README
Red-Portal 05ab711
fix wrong use of transformation in vi
Red-Portal 91606b5
change inital value for scale matrices to 0.6*I and update docs
Red-Portal 722153a
run formatter
Red-Portal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,75 @@ As long as the above functions are defined correctly, Turing will be able to use | |
|
|
||
| The `Turing.Inference.isgibbscomponent(::MySampler)` interface function still exists, but in this version the default has been changed to `true`, so you should not need to overload this. | ||
|
|
||
| ## **AdvancedVI 0.6** | ||
|
|
||
| Turing.jl v0.42 updates `AdvancedVI.jl` compatibility to 0.6 (we skipped the breaking 0.5 update as it does not introduce new features). | ||
| `[email protected]` introduces major structural changes including breaking changes to the interface and multiple new features. | ||
| The summary of the changes below are the things that affect the end-users of Turing. | ||
| For a more comprehensive list of changes, please refer to the [changelogs](https://github.com/TuringLang/AdvancedVI.jl/blob/main/HISTORY.md) in `AdvancedVI`. | ||
|
|
||
| ### Breaking Changes | ||
|
|
||
| A new level of interface for defining different variational algorithms has been introduced in `AdvancedVI` v0.5. As a result, the function `Turing.vi` now receives a keyword argument `algorithm`. The object `algorithm <: AdvancedVI.AbstractVariationalAlgorithm` should now contain all the algorithm-specific configurations. Therefore, keyword arguments of `vi` that were algorithm-specific such as `objective`, `operator`, `averager` and so on, have been moved as fields of the relevant `<: AdvancedVI.AbstractVariationalAlgorithm` structs. | ||
| For example, | ||
|
|
||
| ```julia | ||
| vi(model, q, n_iters; objective=RepGradELBO(10), operator=AdvancedVI.ClipScale()) | ||
| ``` | ||
|
|
||
| is now | ||
|
|
||
| ```julia | ||
| vi( | ||
| model, | ||
| q, | ||
| n_iters; | ||
| algorithm=KLMinRepGradDescent(adtype; n_samples=10, operator=AdvancedVI.ClipScale()), | ||
| ) | ||
| ``` | ||
|
|
||
| Similarly, | ||
|
|
||
| ```julia | ||
| vi( | ||
| model, | ||
| q, | ||
| n_iters; | ||
| objective=RepGradELBO(10; entropy=AdvancedVI.ClosedFormEntropyZeroGradient()), | ||
| operator=AdvancedVI.ProximalLocationScaleEntropy(), | ||
| ) | ||
| ``` | ||
|
|
||
| is now | ||
|
|
||
| ```julia | ||
| vi(model, q, n_iters; algorithm=KLMinRepGradProxDescent(adtype; n_samples=10)) | ||
| ``` | ||
|
|
||
| Additionally, | ||
|
|
||
| - The default hyperparameters of `DoG`and `DoWG` have been altered. | ||
| - The deprecated `[email protected]`-era interface is now removed. | ||
| - `estimate_objective` now returns the value to be minimized by the optimization algorithm. For example, for ELBO maximization algorithms, `estimate_objective` will return the *negative ELBO*. This is breaking change from the previous behavior where the ELBO was returns. | ||
| - The initial value for the `q_meanfield_gaussian`, `q_fullrank_gaussian`, and `q_locationscale` have changed. Specificially, the default initial value for the scale matrix has been changed from `I` to `0.6*I`. | ||
| - When using algorithms that expect to operate in unconstrained spaces, the user is now explicitly expected to provide a `Bijectors.TransformedDistribution` wrapping an unconstrained distribution. (Refer to the docstring of `vi`.) | ||
|
|
||
| ### New Features | ||
|
|
||
| `[email protected]` adds numerous new features including the following new VI algorithms: | ||
|
|
||
| - `KLMinWassFwdBwd`: Also known as "Wasserstein variational inference," this algorithm minimizes the KL divergence under the Wasserstein-2 metric. | ||
| - `KLMinNaturalGradDescent`: This algorithm, also known as "online variational Newton," is the canonical "black-box" natural gradient variational inference algorithm, which minimizes the KL divergence via mirror descent under the KL divergence as the Bregman divergence. | ||
| - `KLMinSqrtNaturalGradDescent`: This is a recent variant of `KLMinNaturalGradDescent` that operates in the Cholesky-factor parameterization of Gaussians instead of precision matrices. | ||
| - `FisherMinBatchMatch`: This algorithm called "batch-and-match," minimizes the variation of the 2nd order fisher divergence via a proximal point-type algorithm. | ||
|
|
||
| Any of the new algorithms above can readily be used by simply swappin the `algorithm` keyword argument of `vi`. | ||
| For example, to use batch-and-match: | ||
|
|
||
| ```julia | ||
| vi(model, q, n_iters; algorithm=FisherMinBatchMatch()) | ||
| ``` | ||
|
|
||
| # 0.41.1 | ||
|
|
||
| The `ModeResult` struct returned by `maximum_a_posteriori` and `maximum_likelihood` can now be wrapped in `InitFromParams()`. | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter v1.0.62] reported by reviewdog 🐶
Turing.jl/docs/src/api.md
Lines 111 to 122 in eaac4c3