Learn R Programming

hann (version 1.2)

tune.hann: Tune Hyperparameters

Description

Tune the two hyperparameters of the neural nets: the number of hidden neurons (H) and the slope of the activation function (beta).

Usage

tune.hann(xi, sigma, classes,
          ranges = list(H = seq(10, 50, by = 10),
                        beta = seq(0.2, 0.8, by = 0.1)),
          nrepeat = 10,
          control = control.hann(iterlim = 20))

Value

a data frame with four columns:

H

the number of hidden neurons

beta

the values of the slope of the activation function

mean

the mean of the error rate computed over the repeats

sd

the standard-deviation

Arguments

xi

a matrix of patterns with K rows.

sigma

a vector coding the Hopfield network.

classes

the classes of the patterns (vector of length K).

ranges

a list giving the values of the parameters to be tested.

nrepeat

the number of repeats

control

the control parameters.

Details

This function is built on the same model than functions in the package e1071.

The effect of the hyperparameters is usually visible with a small number of iterations. The fitting process is repeated several times for each combination of the hyperparameters.

See Also

hann

Examples

Run this code
if (FALSE) {
## simulate 200 random patterns with 30 pixels:
v <- c(-1L, 1L)
K <- 200L
N <- 30L
xi <- matrix(sample(v, K*N, TRUE), K, N)
stopifnot(nrow(unique(xi)) == K)
## build the vector sigma:
sig <- buildSigma(xi, quiet = TRUE)
## define the classes:
cl <- rep(1:2, each = K/2)
## the ranges:
ranges <- list(H = seq(10, 60, by = 10),
               beta = seq(0.1, 1, .1))
ctr <- control.hann(iterlim = 10)
res <- tune.hann(xi, sig, cl, ranges, control = ctr, nrepeat = 5)
str(res)
## visualize the results:
library(lattice)
levelplot(mean ~ beta * H, data = res, main = "Mean")
levelplot(sd ~ beta * H, data = res, main = "Standard-deviation")
}

Run the code above in your browser using DataLab