Skip to content

Commit

Permalink
Refactor Approximate Inference (#194)
Browse files Browse the repository at this point in the history
* First pass at new approx posterior API

* Move elbo to `approx_posterior_gp.jl`

* Update ELBO tests

* Fix elbo tests

* Parameterise VFE type

* Only pass inducing inputs to VFE

* Formatting

* Apply suggestions from code review

Co-authored-by: willtebbutt <[email protected]>

* Explain jitter in docstring

* Update regression example

* Update concrete features docs

* Replace comment

* Apply suggestions from code review

Co-authored-by: st-- <[email protected]>

* Use IrrationalConstants and test type stability

* Add IrrationalConstants compat

* Regenerate docs Manifests

* Refactor again

* Formatting

* Use identity instead of equality

* Bump to 0.4.0

* Bump docs versions

Co-authored-by: willtebbutt <[email protected]>
Co-authored-by: st-- <[email protected]>
  • Loading branch information
3 people authored Aug 20, 2021
1 parent b44dd01 commit 5630f89
Show file tree
Hide file tree
Showing 14 changed files with 359 additions and 291 deletions.
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name = "AbstractGPs"
uuid = "99985d1d-32ba-4be9-9821-2ec096f28918"
authors = ["JuliaGaussianProcesses Team"]
version = "0.3.10"
version = "0.4.0"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b"
IrrationalConstants = "92d709cd-6900-40b7-9082-c6be49f344b6"
KernelFunctions = "ec8451be-7e33-11e9-00cf-bbf324bd1392"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -20,6 +21,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
ChainRulesCore = "1"
Distributions = "0.19, 0.20, 0.21, 0.22, 0.23, 0.24, 0.25"
FillArrays = "0.7, 0.8, 0.9, 0.10, 0.11, 0.12"
IrrationalConstants = "0.1"
KernelFunctions = "0.9, 0.10"
RecipesBase = "1"
Reexport = "0.2, 1"
Expand Down
4 changes: 2 additions & 2 deletions docs/Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ uuid = "a4c015fc-c6ff-483c-b24f-f7ea428134e9"
version = "0.0.1"

[[AbstractGPs]]
deps = ["ChainRulesCore", "Distributions", "FillArrays", "KernelFunctions", "LinearAlgebra", "Random", "RecipesBase", "Reexport", "Statistics", "StatsBase", "Test"]
deps = ["ChainRulesCore", "Distributions", "FillArrays", "IrrationalConstants", "KernelFunctions", "LinearAlgebra", "Random", "RecipesBase", "Reexport", "Statistics", "StatsBase", "Test"]
path = ".."
uuid = "99985d1d-32ba-4be9-9821-2ec096f28918"
version = "0.3.10"
version = "0.4.0"

[[ArgTools]]
uuid = "0dad84c5-d112-42e6-8d28-ef12dabb789f"
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"

[compat]
AbstractGPs = "0.3"
AbstractGPs = "0.4"
Documenter = "0.27"
21 changes: 10 additions & 11 deletions docs/src/concrete_features.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,21 @@ logpdf(f_posterior(x), y)
Here, z is a set of pseudo-points.
```julia
z = randn(rng, 4)
u = f(z)
```

### Evidence Lower BOund (ELBO)
#### Evidence Lower BOund (ELBO)
We provide a ready implentation of elbo w.r.t to the pseudo points. We can perform Variational Inference on pseudo-points by maximizing the ELBO term w.r.t pseudo-points `z` and any kernel parameters. For more information, see [examples](https://github.com/JuliaGaussianProcesses/AbstractGPs.jl/tree/master/examples).
```julia
elbo(fx, y, u)
elbo(VFE(f(z)), fx, y)
```

### Construct the approximate posterior process implied by the VFE approximation.
#### Construct the approximate posterior process implied by the VFE approximation.
The optimal pseudo-points obtained above can be used to create a approximate/sparse posterior. This can be used like a regular posterior in many cases.
```julia
f_approx_posterior = approx_posterior(VFE(), fx, y, u)
f_approx_posterior = posterior(VFE(f(z)), fx, y)
```

### An approximate posterior process is yet another `AbstractGP`, so you can do things with it like
#### An approximate posterior process is yet another `AbstractGP`, so you can do things with it like
```julia
marginals(f_approx_posterior(x))
```
Expand All @@ -87,12 +86,12 @@ p_p_fx = posterior(p_fx(x[4:10], 0.1), y[4:10])
```julia
Z1 = rand(rng, 4)
Z2 = rand(rng, 3)
p_fx = approx_posterior(VFE(), f(x[1:7], 0.1), y[1:7], f(Z))
u_p_fx = update_approx_posterior(p_fx1, f(x[8:10], 0.1), y[8:10])
Z = vcat(Z1, Z2)
p_fx1 = posterior(VFE(f(Z)), f(x[1:7], 0.1), y[1:7])
u_p_fx1 = update_posterior(p_fx1, f(x[8:10], 0.1), y[8:10])
```
##### Adding pseudo-points in an sequential fashion
```julia

p_fx1 = approx_posterior(VFE(), f(X, 0.1), y, f(Z1))
u_p_fx1 = update_approx_posterior(p_fx1, f(Z2))
p_fx2 = posterior(VFE(f(Z1)), f(x, 0.1), y)
u_p_fx2 = update_posterior(p_fx2, f(Z2))
```
Loading

2 comments on commit 5630f89

@willtebbutt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/43432

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.0 -m "<description of version>" 5630f89e68a60bd1bc3292ec453e7e072d0736f5
git push origin v0.4.0

Please sign in to comment.