Skip to content
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

Some bugfixes #125

Merged
merged 3 commits into from
Apr 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ApproximateGPs"
uuid = "298c2ebc-0411-48ad-af38-99e88101b606"
authors = ["JuliaGaussianProcesses Team"]
version = "0.4.0"
version = "0.4.1"

[deps]
AbstractGPs = "99985d1d-32ba-4be9-9821-2ec096f28918"
Expand Down
14 changes: 10 additions & 4 deletions src/LaplaceApproximationModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -179,16 +179,22 @@ function _check_laplace_inputs(
end

struct LaplaceCache{
Tm<:AbstractMatrix,Tv<:AbstractVector,Td<:Diagonal,Tf<:Real,Tc<:Cholesky
Tm<:AbstractMatrix,
Tv1<:AbstractVector,
Tv2<:AbstractVector,
Tv3<:AbstractVector,
Td<:Diagonal,
Tf<:Real,
Tc<:Cholesky,
}
K::Tm # kernel matrix
f::Tv # mode of posterior p(f | y)
f::Tv1 # mode of posterior p(f | y)
W::Td # diagonal matrix of ∂²/∂fᵢ² loglik
Wsqrt::Td # sqrt(W)
loglik::Tf # ∑ᵢlog p(yᵢ|fᵢ)
d_loglik::Tv # ∂/∂fᵢloglik
d_loglik::Tv2 # ∂/∂fᵢloglik
B_ch::Tc # cholesky(I + Wsqrt * K * Wsqrt)
a::Tv # K⁻¹ f
a::Tv3 # K⁻¹ f
end

function _laplace_train_intermediates(dist_y_given_f, ys, K, f)
Expand Down
4 changes: 2 additions & 2 deletions src/SparseVariationalApproximationModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using LinearAlgebra
using Statistics
using StatsBase
using FillArrays: Fill
using PDMats: chol_lower
using PDMats: chol_lower, ScalMat

using AbstractGPs: AbstractGPs
using AbstractGPs:
Expand Down Expand Up @@ -306,7 +306,7 @@ Statistics. PMLR, 2015.
"""
function AbstractGPs.elbo(
sva::SparseVariationalApproximation,
fx::FiniteGP{<:AbstractGP,<:AbstractVector,<:Diagonal{<:Real,<:Fill}},
fx::FiniteGP{<:AbstractGP,<:AbstractVector,<:Union{Diagonal{<:Real,<:Fill},ScalMat}},
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should probably be in a seperate issue, but I think that this is too restrictive of a type constraint - it depends too much on implementation details of AbstractGPs (which is why it broke in the first place) and isn't extensible. I'm pretty sure I wrote it in the first place, so I'll make a PR to change it once this one's in - but what do people think about it?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd be happy for it to become cleaner, go ahead:) - what would be a better way of checking though?

y::AbstractVector{<:Real};
num_data=length(y),
quadrature=DefaultExpectationMethod(),
Expand Down