This file contains 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
using Pkg | |
Pkg.activate(; temp=true) | |
pkg"add AdvancedHMC, LogDensityProblems, LinearAlgebra, Plots, Random, Zygote, Statistics" | |
using AdvancedHMC, LogDensityProblems, LinearAlgebra, Plots, Random, Zygote, Statistics | |
# Define the target distribution using the `LogDensityProblem` interface | |
struct LogTargetDensity | |
dim::Int | |
end | |
LogDensityProblems.logdensity(::LogTargetDensity, θ) = -sum(abs2, θ) / 2 |
This file contains 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
using AbstractGPs, KernelFunctions | |
# Generate toy data. | |
num_dims_in = 5 | |
num_dims_out = 4 | |
num_obs = 100 | |
X = randn(num_obs, num_dims_in) | |
Y = randn(num_obs, num_dims_out) | |
# Convert to format required for AbstractGPs / KernelFunctions. |
This file contains 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
using Revise | |
using AbstractGPs | |
using BenchmarkTools | |
using CUDA | |
using KernelFunctions | |
using LinearAlgebra | |
using Random | |
using AbstractGPs: AbstractGP, FiniteGP, ZeroMean |
This file contains 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 uses the Nabla.jl-style interception mechanism whereby | |
# we wrap things that are to be differentiated w.r.t. in a | |
# thin wrapper. There are lots of thing that you can't | |
# propoagate derivative information through with this kind of | |
# approach without quite a lot of extra machinery, but the | |
# examples at the bottom do work. | |
# | |
using ChainRules, Cassette |