Learn R Programming

darch (version 0.12.0)

darchModelInfo: Creates a custom caret model for darch.

Description

This function creates a caret model description to enable training DArch instances with the train function. See the documentation on custom caret models for further information and examples on how to create valid params and grid values.

Usage

darchModelInfo(params = NULL, grid = NULL)

Arguments

params

data.frame of parameters or NULL to use a simple default (bp.learnRate).

grid

Function which procuces a data.frame containing a grid of parameter combinations or NULL to use a simple default.

Value

A valid caret model which can be passed to train.

See Also

Caret custom models

Examples

Run this code
# NOT RUN {
data(iris)
tc <- trainControl(method = "boot", number = 5, allowParallel = F,
  verboseIter = T)

parameters <- data.frame(parameter = c("layers", "bp.learnRate", "darch.unitFunction"),
  class = c("character", "numeric", "character"),
  label = c("Network structure", "Learning rate", "unitFunction"))

grid <- function(x, y, len = NULL, search = "grid")
{
  df <- expand.grid(layers = c("c(0,20,0)","c(0,10,10,0)","c(0,10,5,5,0)"),
   bp.learnRate = c(1,2,5,10))
  
  df[["darch.unitFunction"]] <- rep(c("c(tanhUnit, softmaxUnit)",
   "c(tanhUnit, tanhUnit, softmaxUnit)",
   "c(tanhUnit, tanhUnit, tanhUnit, softmaxUnit)"), 4)
  
  df
}

caretModel <- train(Species ~ ., data = iris, tuneLength = 12, trControl = tc,
  method = darchModelInfo(parameters, grid), preProc = c("center", "scale"),
  darch.numEpochs = 15, darch.batchSize = 6, testing = T, ...)
# }

Run the code above in your browser using DataLab