#' Define a layer's properties
#'
#' This function produces a description of a \code{layer} in a \code{network}
#'
#' @param nonlinearity a \code{nonlinearity} object describing the activation
#' function used in this layer
#' @param size an integer describing the number of output neurons in this layer.
#' @param prior \code{prior} object for constraining the layer's weights.
#' @param ... additional arguments to be passed to or from other methods
#' (currently not used).
#'
#' @seealso \code{\link{layer}}
#' @include prior.R
#' @include nonlinearity.R
#' @export
defineLayer = function(nonlinearity, size, prior, ...){
assert_that(inherits(nonlinearity, "nonlinearity"))
assert_that(inherits(prior, "prior"))
assert_that(length(size) == 1L)
list(
nonlinearity = nonlinearity,
size = safe.as.integer(size),
prior = prior
)
}
createLayer = function(
n.inputs,
n.outputs,
prior,
nonlinearity,
updater,
n.minibatch,
n.importance.samples
){
coef.updater = updater$copy()
coef.updater$initialize(delta = matrix(0, nrow = n.inputs, ncol = n.outputs))
bias.updater = updater$copy()
bias.updater$initialize(delta = matrix(0, nrow = 1, ncol = n.outputs))
out = layer$new(
coef.dim = c(n.inputs, n.outputs),
weights = matrix(0, nrow = n.inputs, ncol = n.outputs),
biases = matrix(rep(0, n.outputs), nrow = 1),
coef.updater = coef.updater,
bias.updater = bias.updater,
nonlinearity = nonlinearity,
prior = prior
)
out$resetState(n.minibatch, n.importance.samples)
out
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.