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

Feature/marginalise #344

Draft
wants to merge 41 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
312347f
flesh out marginalisation interface
goldingn Jan 7, 2019
1e5e907
add tests for marginalisation error messages
goldingn Jan 7, 2019
3b56a6c
fix typo in marginalisation docs
goldingn Jan 7, 2019
0c766e6
flesh out internals of marginalisation
goldingn Jan 7, 2019
7e802cb
fill in last of guess at internals
goldingn Jan 8, 2019
ad98d72
be strict about float type in as_tf_function
goldingn Jan 8, 2019
9219a42
bugfixes to get marginalise apparently working
goldingn Jan 8, 2019
24fabd1
add marginalisation tests and realted fixes; fix marginalise() example
goldingn Jan 8, 2019
7b9d845
split marginalisers into separate helpfile
goldingn Jan 9, 2019
8689481
flesh out laplace_approximation marginaliser
goldingn Jan 9, 2019
125a989
get laplace approximation (almost) working
goldingn Jan 9, 2019
990e497
finish making laplace approximation run
goldingn Jan 10, 2019
1a8901c
add golden section search and get laplace approximation working
goldingn Jan 11, 2019
f086507
remove stepsize from laplace_approximation options (we optimise it now)
goldingn Jan 11, 2019
0744608
bugfixes and tests to make sure laplace approximation works
goldingn Jan 11, 2019
f6c89e8
Merge branch 'master' into feature/marginalise
goldingn Aug 24, 2019
8e75baf
Merge branch 'master' into feature/marginalise
goldingn Feb 14, 2020
d65ad25
fix lints
goldingn Feb 14, 2020
f8c88dc
fix lints
goldingn Feb 14, 2020
faa9cad
bring marginalisation branch up to date with greta
goldingn Feb 18, 2020
f0c68a2
Merge branch 'master' into feature/marginalise
goldingn Feb 18, 2020
ff34171
more stable computation of discrete marginalisation weights
goldingn Feb 18, 2020
2c6ff39
add posterior conjugate normal test; run short posterior checks every…
goldingn Feb 18, 2020
ddf9e9e
add failing test for laplace approximation
goldingn Feb 18, 2020
18049ea
prepare for non-diagonal hessians
goldingn Feb 18, 2020
e6ae1cb
define distributions as their tfp distribution objects
goldingn Feb 19, 2020
e0f7e23
tidy up tiling to batch size
goldingn Feb 19, 2020
3138eff
stop double-definition of dags
goldingn Feb 19, 2020
8346c8e
enable batch size to be found without access to dag
goldingn Feb 19, 2020
6a02b8d
let marginalisation return the marginalation parameters
goldingn Feb 19, 2020
fd532a5
fix lints
goldingn Feb 19, 2020
57047d8
fix golden section search
goldingn Feb 24, 2020
60ba1b2
stash function calls in gss()
goldingn Feb 24, 2020
5e3dd96
make laplace agree with GRaF
goldingn Feb 26, 2020
2bae9ab
get laplace variances working
goldingn Feb 26, 2020
ca8920b
make laplace work for MVN test case
goldingn Feb 26, 2020
5191f45
bugfix and add notes for univariate Laplace
goldingn Feb 26, 2020
f8b4755
add failing test for univariate normal laplace
goldingn Feb 28, 2020
fc8fe92
switch marginalisers to R6 classes
goldingn Feb 28, 2020
0780a31
pass the distribution to the marginaliser and check inputs early
goldingn Feb 28, 2020
fe40342
get univariate laplace running (with incorrect)
goldingn Feb 28, 2020
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
Prev Previous commit
Next Next commit
fix lints
goldingn committed Feb 14, 2020
commit f8c88dcdd176d3eae06bcfb80fa109ed16feb68a
10 changes: 5 additions & 5 deletions R/marginalisers.R
Original file line number Diff line number Diff line change
@@ -56,7 +56,7 @@ discrete_marginalisation <- function(values) {
# convert these into a list of constant tensors with the correct dimensions
# and float types
values_list <- as.list(values)
values_list <- lapply(values_list, as_2D_array)
values_list <- lapply(values_list, as_2d_array)
values_list <- lapply(values_list, add_first_dim)
values_list <- lapply(values_list, fl)

@@ -182,7 +182,7 @@ laplace_approximation <- function(tolerance = 1e-6,

# here z is a *column vector* to simplify later calculations, it needs to be
# transposed to a row vector before feeding into the likelihood function(s)
z_value <- add_first_dim(as_2D_array(rnorm(n)))
z_value <- add_first_dim(as_2d_array(rnorm(n)))
z <- tf$constant(z_value, dtype = tf_float())

# Newton-Raphson parameters
@@ -192,7 +192,7 @@ laplace_approximation <- function(tolerance = 1e-6,
maxiter <- tf$constant(max_iterations)

# other objects
a_value <- add_first_dim(as_2D_array(rep(0, n)))
a_value <- add_first_dim(as_2d_array(rep(0, n)))
a <- tf$constant(a_value, dtype = tf_float())
u_value <- add_first_dim(diag(n))
u <- tf$constant(u_value, tf_float())
@@ -236,13 +236,13 @@ laplace_approximation <- function(tolerance = 1e-6,
# approximate posterior covariance & cholesky factor
mat1 <- tf$matmul(rw, tf_transpose(rw)) * sigma + eye
u <- tf$cholesky(mat1)
L <- tf_transpose(u)
l <- tf_transpose(u)

# compute Newton-Raphson update direction
b <- w * cf + d1
mat2 <- rw * tf$matmul(sigma, b)
mat3 <- tf$matrix_triangular_solve(u, mat2)
adiff <- b - rw * tf$matrix_triangular_solve(L, mat3, lower = FALSE) - a
adiff <- b - rw * tf$matrix_triangular_solve(l, mat3, lower = FALSE) - a

# use golden section search to find the optimum distance to step in this
# direction, for each batch simultaneously