neuralnet: Training of neural networks

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

Train neural networks using backpropagation, resilient backpropagation (RPROP) with (Riedmiller, 1994) or without weight backtracking (Riedmiller and Braun, 1993) or the modified globally convergent version (GRPROP) by Anastasiadis et al. (2005). The function allows flexible settings through custom-choice of error and activation function. Furthermore, the calculation of generalized weights (Intrator O. and Intrator N., 1993) is implemented.

Usage

1
2
3
4
5
6
7
neuralnet(formula, data, hidden = 1, threshold = 0.01,
  stepmax = 1e+05, rep = 1, startweights = NULL,
  learningrate.limit = NULL, learningrate.factor = list(minus = 0.5,
  plus = 1.2), learningrate = NULL, lifesign = "none",
  lifesign.step = 1000, algorithm = "rprop+", err.fct = "sse",
  act.fct = "logistic", linear.output = TRUE, exclude = NULL,
  constant.weights = NULL, likelihood = FALSE)

Arguments

formula

a symbolic description of the model to be fitted.

data

a data frame containing the variables specified in formula.

hidden

a vector of integers specifying the number of hidden neurons (vertices) in each layer.

threshold

a numeric value specifying the threshold for the partial derivatives of the error function as stopping criteria.

stepmax

the maximum steps for the training of the neural network. Reaching this maximum leads to a stop of the neural network's training process.

rep

the number of repetitions for the neural network's training.

startweights

a vector containing starting values for the weights. Set to NULL for random initialization.

learningrate.limit

a vector or a list containing the lowest and highest limit for the learning rate. Used only for RPROP and GRPROP.

learningrate.factor

a vector or a list containing the multiplication factors for the upper and lower learning rate. Used only for RPROP and GRPROP.

learningrate

a numeric value specifying the learning rate used by traditional backpropagation. Used only for traditional backpropagation.

lifesign

a string specifying how much the function will print during the calculation of the neural network. 'none', 'minimal' or 'full'.

lifesign.step

an integer specifying the stepsize to print the minimal threshold in full lifesign mode.

algorithm

a string containing the algorithm type to calculate the neural network. The following types are possible: 'backprop', 'rprop+', 'rprop-', 'sag', or 'slr'. 'backprop' refers to backpropagation, 'rprop+' and 'rprop-' refer to the resilient backpropagation with and without weight backtracking, while 'sag' and 'slr' induce the usage of the modified globally convergent algorithm (grprop). See Details for more information.

err.fct

a differentiable function that is used for the calculation of the error. Alternatively, the strings 'sse' and 'ce' which stand for the sum of squared errors and the cross-entropy can be used.

act.fct

a differentiable function that is used for smoothing the result of the cross product of the covariate or neurons and the weights. Additionally the strings, 'logistic' and 'tanh' are possible for the logistic function and tangent hyperbolicus.

linear.output

logical. If act.fct should not be applied to the output neurons set linear output to TRUE, otherwise to FALSE.

exclude

a vector or a matrix specifying the weights, that are excluded from the calculation. If given as a vector, the exact positions of the weights must be known. A matrix with n-rows and 3 columns will exclude n weights, where the first column stands for the layer, the second column for the input neuron and the third column for the output neuron of the weight.

constant.weights

a vector specifying the values of the weights that are excluded from the training process and treated as fix.

likelihood

logical. If the error function is equal to the negative log-likelihood function, the information criteria AIC and BIC will be calculated. Furthermore the usage of confidence.interval is meaningfull.

Details

The globally convergent algorithm is based on the resilient backpropagation without weight backtracking and additionally modifies one learning rate, either the learningrate associated with the smallest absolute gradient (sag) or the smallest learningrate (slr) itself. The learning rates in the grprop algorithm are limited to the boundaries defined in learningrate.limit.

Value

neuralnet returns an object of class nn. An object of class nn is a list containing at most the following components:

call

the matched call.

response

extracted from the data argument.

covariate

the variables extracted from the data argument.

model.list

a list containing the covariates and the response variables extracted from the formula argument.

err.fct

the error function.

act.fct

the activation function.

data

the data argument.

net.result

a list containing the overall result of the neural network for every repetition.

weights

a list containing the fitted weights of the neural network for every repetition.

generalized.weights

a list containing the generalized weights of the neural network for every repetition.

result.matrix

a matrix containing the reached threshold, needed steps, error, AIC and BIC (if computed) and weights for every repetition. Each column represents one repetition.

startweights

a list containing the startweights of the neural network for every repetition.

Author(s)

Stefan Fritsch, Frauke Guenther, Marvin N. Wright

References

Riedmiller M. (1994) Rprop - Description and Implementation Details. Technical Report. University of Karlsruhe.

Riedmiller M. and Braun H. (1993) A direct adaptive method for faster backpropagation learning: The RPROP algorithm. Proceedings of the IEEE International Conference on Neural Networks (ICNN), pages 586-591. San Francisco.

Anastasiadis A. et. al. (2005) New globally convergent training scheme based on the resilient propagation algorithm. Neurocomputing 64, pages 253-270.

Intrator O. and Intrator N. (1993) Using Neural Nets for Interpretation of Nonlinear Models. Proceedings of the Statistical Computing Section, 244-249 San Francisco: American Statistical Society (eds).

See Also

plot.nn for plotting the neural network.

gwplot for plotting the generalized weights.

predict.nn for computation of a given neural network for given covariate vectors (formerly compute).

confidence.interval for calculation of confidence intervals of the weights.

prediction for a summary of the output of the neural network.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(neuralnet)

# Binary classification
nn <- neuralnet(Species == "setosa" ~ Petal.Length + Petal.Width, iris, linear.output = FALSE)
## Not run: print(nn)
## Not run: plot(nn)

# Multiclass classification
nn <- neuralnet(Species ~ Petal.Length + Petal.Width, iris, linear.output = FALSE)
## Not run: print(nn)
## Not run: plot(nn)

# Custom activation function
softplus <- function(x) log(1 + exp(x))
nn <- neuralnet((Species == "setosa") ~ Petal.Length + Petal.Width, iris, 
                linear.output = FALSE, hidden = c(3, 2), act.fct = softplus)
## Not run: print(nn)
## Not run: plot(nn)

neuralnet documentation built on May 2, 2019, 9:17 a.m.