BNN {BayesFluxR} | R Documentation |
Create a Bayesian Neural Network
Description
Create a Bayesian Neural Network
Usage
BNN(x, y, like, prior, init)
Arguments
x |
For a Feedforward structure, this must be a matrix of dimensions variables x observations; For a recurrent structure, this must be a tensor of dimensions sequence_length x number_variables x number_sequences; In general, the last dimension is always the dimension over which will be batched. |
y |
A vector or matrix with observations. |
like |
Likelihood; See for example |
prior |
Prior; See for example |
init |
Initialiser; See for example |
Value
List with the following content
'juliavar' - the julia variable containing the BNN
'juliacode' - the string representation of the BNN
'x' - x
'juliax' - julia variable holding x
'y' - y
'juliay' - julia variable holding y
Examples
## 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.SGLD()
ch <- mcmc(bnn, 10, 1000, sampler)
## End(Not run)
[Package BayesFluxR version 0.1.3 Index]