Description Usage Arguments Value Examples
This function can be used to teach an ANN to minimise arbitrary objective function.
1 2 | mlp_teach_sa(net, obj_func, Tinit = 1, epochs = 1000, report_freq = 0,
report_action = NULL)
|
net |
an object of |
obj_func |
function taking an object of |
Tinit |
numeric value, initial temperature (default is 1) |
epochs |
integer value, number of epochs (iterations) (default is 1000) |
report_freq |
integer value, progress report frequency, if set to 0 no information is printed on the console (this is the default) |
report_action |
function (or NULL), additional action to be taken while printing progress reports, this should be a function taking network as a single argument (default NULL) |
Two-element list, the first field (net
) contains the trained network,
the second (obj
) - the learning history (value of the objective
function in consecutive epochs).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
# set up XOR problem
inp <- c(0, 0, 1, 1, 0, 1, 0, 1)
dim(inp) <- c(4, 2)
outp <- c(0, 1, 1, 0)
dim(outp) <- c(4, 1)
# objective
obj <- function(net)
{
return(mlp_mse(net, inp, outp))
}
# create a 2-6-1 network
net <- mlp_net(c(2, 6, 1))
# set activation function in all layers
net <- mlp_set_activation(net, layer = "a", "sigmoid")
# teach
netobj <- mlp_teach_sa(net, obj, Tinit = 1, epochs = 1000,
report_freq = 1)
# plot learning history
plot(netobj$obj, type = 'l')
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.