| Title: | Artificial Neural Network Training and Simulating |
|---|---|
| Description: | Commands for training a simulating an artificial neural network. Compatibility updates by Renova. |
| Authors: | Manuel Castejon Limas, Joaquin B. Ordieres Mere, Ana Gonzalez Marcos, Francisco Javier Martinez de Pison Ascacibar, Alpha V. Pernia Espinoza, Fernando Alba Elias, Jose Maria Perez Ramos |
| Maintainer: | Manuel Castejón-Limas <[email protected]> |
| License: | GPL (>= 2) |
| Version: | 0.2.16.9002 |
| Built: | 2026-11-15 21:44:08 UTC |
| Source: | https://github.com/renova-r/AMORE |
Adaptative gradient descent training method.
ADAPTgd.MLPnet(net,P, T,n.epochs, n.threads=0L)ADAPTgd.MLPnet(net,P, T,n.epochs, n.threads=0L)
net |
Neural Network to train. |
P |
Input data set. |
T |
Target output data set. |
n.epochs |
Number of epochs to train |
n.threads |
Unused, but required to match the BATCH* function template. |
This function returns a neural network object modified according to the input and target data set.
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré. [email protected]
Ana González Marcos. [email protected]
Alpha V. Pernía Espinoza. [email protected]
Francisco Javier Martinez de Pisón. [email protected]
Fernando Alba Elías. [email protected]
Simon Haykin. Neural Networks – a Comprehensive Foundation. Prentice Hall, New Jersey, 2nd edition, 1999. ISBN 0-13-273350-1.
Adaptative gradient descent with momentum training method.
ADAPTgdwm.MLPnet(net,P, T,n.epochs, n.threads=0L)ADAPTgdwm.MLPnet(net,P, T,n.epochs, n.threads=0L)
net |
Neural Network to train. |
P |
Input data set. |
T |
Target output data set. |
n.epochs |
Number of epochs to train |
n.threads |
Unused, but required to match the BATCH* function template. |
This function returns a neural network object modified according to the input and target data set.
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré. [email protected]
Ana González Marcos. [email protected]
Alpha V. Pernía Espinoza. [email protected]
Francisco Javier Martinez de Pisón. [email protected]
Fernando Alba Elías. [email protected]
Simon Haykin. Neural Networks – a Comprehensive Foundation. Prentice Hall, New Jersey, 2nd edition, 1999. ISBN 0-13-273350-1.
Modifies the neural network weights and biases according to the training set.
BATCHgd.MLPnet(net,P,T,n.epochs, n.threads=0L)BATCHgd.MLPnet(net,P,T,n.epochs, n.threads=0L)
net |
Neural Network to train. |
P |
Input data set. |
T |
Target output data set. |
n.epochs |
Number of epochs to train |
n.threads |
Number of threads to spawn. If <1, spawns NumberProcessors-1 threads. If no OpenMP is found, this argument will be ignored. |
This function returns a neural network object modified according to the chosen data.
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré. [email protected]
Ana González Marcos. [email protected]
Alpha V. Pernía Espinoza. [email protected]
Francisco Javier Martinez de Pisón. [email protected]
Fernando Alba Elías. [email protected]
Simon Haykin. Neural Networks – a Comprehensive Foundation. Prentice Hall, New Jersey, 2nd edition, 1999. ISBN 0-13-273350-1.
Modifies the neural network weights and biases according to the training set.
BATCHgdwm.MLPnet(net,P,T, n.epochs, n.threads=0L)BATCHgdwm.MLPnet(net,P,T, n.epochs, n.threads=0L)
net |
Neural Network to train. |
P |
Input data set. |
T |
Target output data set. |
n.epochs |
Number of epochs to train |
n.threads |
Number of threads to spawn. If <1, spawns NumberProcessors-1 threads. If no OpenMP is found, this argument will be ignored. |
This functions returns a neural network object modified according to the chosen data.
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré. [email protected]
Ana González Marcos. [email protected]
Alpha V. Pernía Espinoza. [email protected]
Francisco Javier Martinez de Pisón. [email protected]
Fernando Alba Elías. [email protected]
Simon Haykin. Neural Networks – a Comprehensive Foundation. Prentice Hall, New Jersey, 2nd edition, 1999. ISBN 0-13-273350-1.
The error functions calculate the goodness of fit of a neural network according to certain criterium:
LMS: Least Mean Squares Error.
LMLS: Least Mean Log Squares minimization.
TAO: TAO error minimization.
The deltaE functions calculate the influence functions of their error criteria.
error.LMS(arguments) error.LMLS(arguments) error.TAO(arguments) deltaE.LMS(arguments) deltaE.LMLS(arguments) deltaE.TAO(arguments)error.LMS(arguments) error.LMLS(arguments) error.TAO(arguments) deltaE.LMS(arguments) deltaE.LMLS(arguments) deltaE.TAO(arguments)
arguments |
List of arguments to pass to the functions.
|
This functions return the error and influence function criteria.
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré. [email protected]
Ana González Marcos. [email protected]
Alpha V. Pernía Espinoza. [email protected]
Francisco Javier Martinez de Pisón. [email protected]
Fernando Alba Elías. [email protected]
Pernía Espinoza, A.V., Ordieres Meré, J.B., Martínez de Pisón, F.J., González Marcos, A. TAO-robust backpropagation learning algorithm. Neural Networks. Vol. 18, Issue 2, pp. 191–204, 2005.
Simon Haykin. Neural Networks – a Comprehensive Foundation. Prentice Hall, New Jersey, 2nd edition, 1999. ISBN 0-13-273350-1.
Auxiliar functions. Not meant to be called from the user but from the error.TAO and the deltaE.TAO functions.
hfun(v,k) phifun(v,k) dphifun(v,k)hfun(v,k) phifun(v,k) dphifun(v,k)
v |
Input value. |
k |
Threshold limit. |
These functions return a numeric array with dimension equal to the dimension of v.
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré. [email protected]
Ana González Marcos. [email protected]
Alpha V. Pernía Espinoza. [email protected]
Francisco Javier Martinez de Pisón. [email protected]
Fernando Alba Elías. [email protected]
Pernía Espinoza, A.V., Ordieres Meré, J.B., Martínez de Pisón, F.J., González Marcos, A. TAO-robust backpropagation learning algorithm. Neural Networks. Vol. 18, Issue 2, pp. 191–204, 2005.
Simon Haykin. Neural Networks – a Comprehensive Foundation. Prentice Hall, New Jersey, 2nd edition, 1999. ISBN 0-13-273350-1.
Creates a dot file, suitable to be processed with graphviz, containing a graphical representation of the netwok topology and some numerical information about the network parameters.
graphviz.MLPnet(net, filename, digits)graphviz.MLPnet(net, filename, digits)
net |
Neural Network. |
filename |
Name of the dot file to be written. |
digits |
Number of digits used to round the parameters. |
This function writes a file suitable to be postprocessed with the graphviz package. Thus, multiple formats can be obtained: ps, pdf, ...
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré. [email protected]
Ana González Marcos. [email protected]
Alpha V. Pernía Espinoza. [email protected]
Francisco Javier Martinez de Pisón. [email protected]
Fernando Alba Elías. [email protected]
http:\/\/www.graphviz.org
Creates a neuron according to the structure established by the AMORE package standard.
init.MLPneuron(id, type, activation.function, output.links, output.aims, input.links, weights, bias, method, method.dep.variables)init.MLPneuron(id, type, activation.function, output.links, output.aims, input.links, weights, bias, method, method.dep.variables)
id |
Numerical index of the neuron (so as to be refered in a network operation). |
type |
Either hidden or ouput, according to the layer the neuron belongs to. |
activation.function |
The name of the characteristic function of the neuron. It can be "pureline", "tansig", "sigmoid" or even "custom" in case that the user wants to configure its own activation function accordingly defining f0 and f1. |
output.links |
The id's of the neurons that accept the output value of this neuron as an input. |
output.aims |
The location of the output of the neuron in the input set of the addressed neuron. Gives answer to: Is this output the first, the second, the third, ..., input at the addressed neuron?. Similarly for an output neuron: Is this output the first, the second, the third, ..., element of the output vector? |
input.links |
The id's of the neurons whose outputs work as inputs for this neuron. Positive values represent that we take the outputs of other neurons as inputs. Negative values represent the coordinates of the input vector to be considered as inputs. |
weights |
The multiplying factors of the input values. |
bias |
The bias summed to the weighted sum of the inputs. |
method |
Prefered training method. Currently it can be:
|
method.dep.variables |
Variables used by the training methods:
|
init.MLPneuron returns a single neuron. Mainly used to create a neural network object.
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré. [email protected]
Ana González Marcos. [email protected]
Alpha V. Pernía Espinoza. [email protected]
Francisco Javier Martinez de Pisón. [email protected]
Fernando Alba Elías. [email protected]
newff, random.init.MLPnet, random.init.MLPneuron, select.activation.function , init.MLPneuron
Creates a feedforward artificial neural network according to the structure established by the AMORE package standard.
newff(n.neurons, learning.rate.global, momentum.global, error.criterium, Stao, hidden.layer, output.layer, method)newff(n.neurons, learning.rate.global, momentum.global, error.criterium, Stao, hidden.layer, output.layer, method)
n.neurons |
Numeric vector containing the number of neurons of each layer. The first element of the vector is the number of input neurons, the last is the number of output neurons and the rest are the number of neuron of the different hidden layers. |
learning.rate.global |
Learning rate at which every neuron is trained. |
momentum.global |
Momentum for every neuron. Needed by several training methods. |
error.criterium |
Criterium used to measure to proximity of the neural network prediction to its target. Currently we can choose amongst:
|
Stao |
Stao parameter for the TAO error criterium. Unused by the rest of criteria. |
|
Activation function of the hidden layer neurons. Available functions are:
|
|
output.layer |
Activation function of the hidden layer neurons according to the former list shown above. |
method |
Prefered training method. Currently it can be:
|
newff returns a multilayer feedforward neural network object.
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré.
Ana González Marcos.
Alpha V. Pernía Espinoza.
Eliseo P. Vergara Gonzalez.
Francisco Javier Martinez de Pisón.
Fernando Alba Elías.
Pernía Espinoza, A.V., Ordieres Meré, J.B., Martínez de Pisón, F.J., González Marcos, A. TAO-robust backpropagation learning algorithm. Neural Networks. Vol. 18, Issue 2, pp. 191–204, 2005.
Simon Haykin. Neural Networks – a Comprehensive Foundation. Prentice Hall, New Jersey, 2nd edition, 1999. ISBN 0-13-273350-1.
init.MLPneuron, random.init.MLPnet, random.init.MLPneuron, select.activation.function
#Example 1 library(AMORE) # P is the input vector P <- matrix(sample(seq(-1,1,length=1000), 1000, replace=FALSE), ncol=1) # The network will try to approximate the target P^2 target <- P^2 # We create a feedforward network, with two hidden layers. # The first hidden layer has three neurons and the second has two neurons. # The hidden layers have got Tansig activation functions and the output layer is Purelin. net <- newff(n.neurons=c(1,3,2,1), learning.rate.global=1e-2, momentum.global=0.5, error.criterium="LMS", Stao=NA, hidden.layer="tansig", output.layer="purelin", method="ADAPTgdwm") result <- train(net, P, target, error.criterium="LMS", report=TRUE, show.step=100, n.shows=5 ) y <- sim(result$net, P) plot(P,y, col="blue", pch="+") points(P,target, col="red", pch="x")#Example 1 library(AMORE) # P is the input vector P <- matrix(sample(seq(-1,1,length=1000), 1000, replace=FALSE), ncol=1) # The network will try to approximate the target P^2 target <- P^2 # We create a feedforward network, with two hidden layers. # The first hidden layer has three neurons and the second has two neurons. # The hidden layers have got Tansig activation functions and the output layer is Purelin. net <- newff(n.neurons=c(1,3,2,1), learning.rate.global=1e-2, momentum.global=0.5, error.criterium="LMS", Stao=NA, hidden.layer="tansig", output.layer="purelin", method="ADAPTgdwm") result <- train(net, P, target, error.criterium="LMS", report=TRUE, show.step=100, n.shows=5 ) y <- sim(result$net, P) plot(P,y, col="blue", pch="+") points(P,target, col="red", pch="x")
Provides random values to the network weights and biases so as to start with. Basically it applies the random.init.MLPneuron function to every neuron in the network.
random.init.MLPnet(net)random.init.MLPnet(net)
net |
The neural network object |
random.init.MLPnet returns the input network with weights and biases changed randomly.
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré. [email protected]
Ana González Marcos. [email protected]
Alpha V. Pernía Espinoza. [email protected]
Francisco Javier Martinez de Pisón. [email protected]
Fernando Alba Elías. [email protected]
random.init.MLPneuron, init.MLPneuron, newff
Provides random values to the neuron weights and bias so as to start with. It is usually called by the random.init.NeuralNet function during the construction of the neural object by the newff function.
random.init.MLPneuron(net.number.weights, neuron)random.init.MLPneuron(net.number.weights, neuron)
net.number.weights |
Number of bias and weight parameters of the neural network the neuron belongs to. |
neuron |
The neuron object. |
The values are assigned according to the suggestions of Haykin.
random.init.MLPneuron returns the input neuron with bias and weights changed randomly.
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré. [email protected]
Ana González Marcos. [email protected]
Alpha V. Pernía Espinoza. [email protected]
Francisco Javier Martinez de Pisón. [email protected]
Fernando Alba Elías. [email protected]
Simon Haykin. Neural Networks – a Comprehensive Foundation. Prentice Hall, New Jersey, 2nd edition, 1999. ISBN 0-13-273350-1.
random.init.MLPnet, init.MLPneuron, newff
Provides random values to the neuron weights and bias so as to start with. It is usually called by the random.init.NeuralNet function during the construction of the neural object by the newff function.
select.activation.function(activation.function)select.activation.function(activation.function)
activation.function |
Activation function name. Currently the user may choose amongst purelin, tansig, sigmoid, hardlim and custom. If custom is chosen the the user must manually assign the neuron f0 and f1 functions. |
select.activation.function returns a list with two elements. The first, f0 is the R code selected to serve as the neuron activation function. The second, f1 is the R code of the activation function derivative.
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré. [email protected]
Ana González Marcos. [email protected]
Alpha V. Pernía Espinoza. [email protected]
Francisco Javier Martinez de Pisón. [email protected]
Fernando Alba Elías. [email protected]
This function calculates the output values of the neural network for a given data set. Various versions are provided according to different degrees of C code conversion. The sim.MLPnet function is the latest and quickest.
sim(net,P,...) #sim.MLPnet(net,P,...)sim(net,P,...) #sim.MLPnet(net,P,...)
... |
Currently, the parameters below are accepted. |
net |
Neural Network to simulate. |
P |
Data Set input values. |
This function returns a matrix containing the output values of the neural network for the given data set.
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré [email protected]
Ana González Marcos. [email protected]
Alpha V. Pernía Espinoza. [email protected]
Francisco Javier Martinez de Pisón [email protected]
Fernando Alba Elías. [email protected]
Simon Haykin. Neural Networks – a Comprehensive Foundation. Prentice Hall, New Jersey, 2nd edition, 1999. ISBN 0-13-273350-1.
For a given data set (training set), this function modifies the neural network weights and biases to approximate the relationships amongst variables present in the training set. These may serve to satisfy several needs, i.e. fitting non-linear functions.
train(net, P, T, Pval=NULL, Tval=NULL, error.criterium="LMS", report=TRUE, n.shows, show.step, Stao=NA,prob=NULL,n.threads=0L)train(net, P, T, Pval=NULL, Tval=NULL, error.criterium="LMS", report=TRUE, n.shows, show.step, Stao=NA,prob=NULL,n.threads=0L)
net |
Neural Network to train. |
P |
Training set input values. |
T |
Training set output values |
Pval |
Validation set input values for optional early stopping. |
Tval |
Validation set output values for optional early stopping. |
error.criterium |
Criterium used to measure the goodness of fit:"LMS", "LMLS", "TAO". |
Stao |
Initial value of the S parameter used by the TAO algorithm. |
report |
Logical value indicating whether the training function should keep quiet or should provide graphical/written information during the training process instead. |
n.shows |
Number of times to report (if report is TRUE). The total number of training epochs is n.shows times show.step. |
show.step |
Number of epochs to train non-stop until the training function is allow to report. |
prob |
Vector with the probabilities of each sample so as to apply resampling training. |
n.threads |
Number of threads to spawn for the BATCH* training methods. If <1, spawns NumberProcessors-1 threads. If no OpenMP is found, this argument will be ignored. |
This function returns a list with two elements: the trained Neural Network object with weights and biases adjusted by the adaptative backpropagation with momentum method and a matrix with the errors obtained during the training. If the validation set is provided, the early stopping technique is applied.
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré [email protected]
Ana González Marcos. [email protected]
Alpha V. Pernía Espinoza. [email protected]
Francisco Javier Martinez de Pisón. [email protected]
Fernando Alba Elías. [email protected]
Pernía Espinoza, A.V., Ordieres Meré, J.B., Martínez de Pisón, F.J., González Marcos, A. TAO-robust backpropagation learning algorithm. Neural Networks. Vol. 18, Issue 2, pp. 191–204, 2005.
Simon Haykin. Neural Networks – a Comprehensive Foundation. Prentice Hall, New Jersey, 2nd edition, 1999. ISBN 0-13-273350-1.
Function in charge of reporting the behavior of the network training. The users should modify this function according to their needs.
training.report(net,P,T, idx.show, error.criterium)training.report(net,P,T, idx.show, error.criterium)
net |
Neural Network to train. |
P |
Training set input values. |
T |
Training set output values |
idx.show |
Current show index. |
error.criterium |
Criterium used to measure the goodness of fit. |
This function does not return any value. Just useful for printing and plotting.
Manuel Castejón Limas. [email protected]
Joaquin Ordieres Meré. [email protected]
Ana González Marcos. [email protected]
Alpha V. Pernía Espinoza. [email protected]
Francisco Javier Martinez de Pisón. [email protected]
Fernando Alba Elías. [email protected]
Simon Haykin. Neural Networks – a Comprehensive Foundation. Prentice Hall, New Jersey, 2nd edition, 1999. ISBN 0-13-273350-1.