darchModelInfo: Creates a custom caret model for 'darch'.

Description Usage Arguments Value See Also Examples

View source: R/caret.R

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

1

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
## 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, ...)

## End(Not run)

maddin79/darch documentation built on May 21, 2019, 10:53 a.m.