Training of neural networks
neuralnet is used to 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
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)
- a symbolic description of the model to be fitted.
- a data frame containing the variables specified in
- a vector of integers specifying the number of hidden neurons (vertices) in each layer.
- a numeric value specifying the threshold for the partial derivatives of the error function as stopping criteria.
- the maximum steps for the training of the neural network. Reaching this maximum leads to a stop of the neural network's training process.
- the number of repetitions for the neural network's training.
- a vector containing starting values for the weights. The weights will not be randomly initialized.
- a vector or a list containing the lowest and highest limit for the learning rate. Used only for RPROP and GRPROP.
- a vector or a list containing the multiplication factors for the upper and lower learning rate. Used only for RPROP and GRPROP.
- a numeric value specifying the learning rate used by traditional backpropagation. Used only for traditional backpropagation.
- a string specifying how much the function will print during the calculation of the neural network. 'none', 'minimal' or 'full'.
- an integer specifying the stepsize to print the minimal threshold in full lifesign mode.
- 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.
- 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.
- 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.
- logical. If act.fct should not be applied to the output neurons set linear output to TRUE, otherwise to FALSE.
- 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.
- a vector specifying the values of the weights that are excluded from the training process and treated as fix.
- 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.
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.
neuralnetreturns an object of class
nn. An object of class
nnis a list containing at most the following components:
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).
plot.nn for plotting the neural network.
gwplot for plotting the generalized weights.
compute for computation of a given neural network for given covariate vectors.
confidence.interval for calculation of confidence intervals of the weights.
prediction for a summary of the output of the neural network.
AND <- c(rep(0,7),1) OR <- c(0,rep(1,7)) binary.data <- data.frame(expand.grid(c(0,1), c(0,1), c(0,1)), AND, OR) print(net <- neuralnet(AND+OR~Var1+Var2+Var3, binary.data, hidden=0, rep=10, err.fct="ce", linear.output=FALSE)) data(infert, package="datasets") print(net.infert <- neuralnet(case~parity+induced+spontaneous, infert, err.fct="ce", linear.output=FALSE, likelihood=TRUE))