mcmc {BayesFluxR} | R Documentation |
Sample from a BNN using MCMC
mcmc(
bnn,
batchsize,
numsamples,
sampler = sampler.SGLD(stepsize_a = 1),
continue_sampling = FALSE,
start_value = NULL
)
bnn |
A BNN obtained using |
batchsize |
batchsize to use; Most samplers allow for batching. For some, theoretical justifications are missing (HMC) |
numsamples |
Number of mcmc samples |
sampler |
Sampler to use; See for example |
continue_sampling |
Do not start new sampling, but rather continue sampling For this, numsamples must be greater than the already sampled number. |
start_value |
Values to start from. By default these will be sampled using the initialiser in 'bnn'. |
a list containing the 'samples' and the 'sampler' used.
## Not run:
## Needs previous call to `BayesFluxR_setup` which is time
## consuming and requires Julia and BayesFlux.jl
BayesFluxR_setup(installJulia=TRUE, seed=123)
net <- Chain(Dense(5, 1))
like <- likelihood.feedforward_normal(net, Gamma(2.0, 0.5))
prior <- prior.gaussian(net, 0.5)
init <- initialise.allsame(Normal(0, 0.5), like, prior)
x <- matrix(rnorm(5*100), nrow = 5)
y <- rnorm(100)
bnn <- BNN(x, y, like, prior, init)
sampler <- sampler.SGNHTS(1e-3)
ch <- mcmc(bnn, 10, 1000, sampler)
## End(Not run)