|
| 1 | +@doc raw""" |
| 2 | + LinearMixingModelKernel(g, e::MOKernel, A::AbstractMatrix) |
| 3 | +
|
| 4 | +Kernel associated with the linear mixing model. |
| 5 | +
|
| 6 | +# Definition |
| 7 | +
|
| 8 | +For inputs ``x, x'`` and output dimensions ``p_x, p_{x'}'``, the kernel is defined as[^BPTHST] |
| 9 | +```math |
| 10 | +k\big((x, p_x), (x, p_{x'})\big) = H_{:,p_{x}}K(x, x')H_{:,p_{x'}} |
| 11 | +``` |
| 12 | +where ``K(x, x') = Diag(k_1(x, x'), ..., k_m(x, x'))`` with zero off-diagonal entries. |
| 13 | +``H_{:,p_{x}}`` is the ``p_x``-th column (`p_x`-th output) of ``H \in \mathbb{R}^{m \times p}`` |
| 14 | +representing ``m`` basis vectors for the ``p`` dimensional output space of ``f``. |
| 15 | +``k_1, \ldots, k_m`` are ``m`` kernels, one for each latent process, ``H`` is a |
| 16 | +mixing matrix of ``m`` basis vectors spanning the output space. |
| 17 | +
|
| 18 | +[^BPTHST]: Wessel P. Bruinsma, Eric Perim, Will Tebbutt, J. Scott Hosking, Arno Solin, Richard E. Turner (2020). [Scalable Exact Inference in Multi-Output Gaussian Processes](https://arxiv.org/pdf/1911.06287.pdf). |
| 19 | +""" |
| 20 | +struct LinearMixingModelKernel{Tk<:AbstractVector{<:Kernel},Th<:AbstractMatrix} <: MOKernel |
| 21 | + K::Tk |
| 22 | + H::Th |
| 23 | +end |
| 24 | + |
| 25 | +function LinearMixingModelKernel(k::Kernel, H::AbstractMatrix) |
| 26 | + return LinearMixingModelKernel(Fill(k, size(H, 1)), H) |
| 27 | +end |
| 28 | + |
| 29 | +function (κ::LinearMixingModelKernel)((x, px)::Tuple{Any,Int}, (y, py)::Tuple{Any,Int}) |
| 30 | + (px > size(κ.H, 2) || py > size(κ.H, 2) || px < 1 || py < 1) && |
| 31 | + error("`px` and `py` must be within the range of the number of outputs") |
| 32 | + return sum(κ.H[i, px] * κ.K[i](x, y) * κ.H[i, py] for i in 1:length(κ.K)) |
| 33 | +end |
| 34 | + |
| 35 | +function Base.show(io::IO, k::LinearMixingModelKernel) |
| 36 | + return print(io, "Linear Mixing Model Multi-Output Kernel") |
| 37 | +end |
| 38 | + |
| 39 | +function Base.show(io::IO, mime::MIME"text/plain", k::LinearMixingModelKernel) |
| 40 | + print(io, "Linear Mixing Model Multi-Output Kernel. Kernels:") |
| 41 | + for k in k.K |
| 42 | + print(io, "\n\t") |
| 43 | + show(io, mime, k) |
| 44 | + end |
| 45 | +end |
0 commit comments