Learn R Programming

BayesFluxR (version 0.1.3)

likelihood.seqtoone_normal: Use a Normal likelihood for a seq-to-one recurrent network

Description

This creates a likelihood of the form $$y_i \sim Normal(net(x_i), \sigma), i=1,...,N$$ Here \(x_i\) is a subsequence which will be fed through the recurrent network to obtain the final output \(net(x_i) = \hat{y}_i\). Thus, if one has a single time series, and splits the single time series into subsequences of length K which are then used to predict the next output of the time series, then each \(x_i\) consists of K consecutive observations of the time series. In a sense one constraints the maximum memory length of the network this way.

Usage

likelihood.seqtoone_normal(chain, sig_prior)

Value

see likelihood.feedforward_normal

Arguments

chain

Network structure obtained using link{Chain}

sig_prior

A prior distribution for sigma defined using Gamma, link{InverGamma}, Truncated, Normal

Examples

Run this code
if (FALSE) {
  ## Needs previous call to `BayesFluxR_setup` which is time
  ## consuming and requires Julia and BayesFlux.jl
  BayesFluxR_setup(installJulia=TRUE, seed=123)
  net <- Chain(RNN(5, 1))
  like <- likelihood.seqtoone_normal(net, Gamma(2.0, 0.5))
  prior <- prior.gaussian(net, 0.5)
  init <- initialise.allsame(Normal(0, 0.5), like, prior)
  x <- array(rnorm(5*100*10), dim=c(10,5,100))
  y <- rnorm(100)
  bnn <- BNN(x, y, like, prior, init)
  BNN.totparams(bnn)
}

Run the code above in your browser using DataLab