mlp_teach_sa: Teaching networks using Simulated Annealing

Description Usage Arguments Value Examples

View source: R/mlp_gteach.R

Description

This function can be used to teach an ANN to minimise arbitrary objective function.

Usage

1
2
mlp_teach_sa(net, obj_func, Tinit = 1, epochs = 1000, report_freq = 0,
  report_action = NULL)

Arguments

net

an object of mlp_net class

obj_func

function taking an object of mlp_class class as a single argument returning objective to be minimised

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)

Value

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).

Examples

 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)

FCNN4R documentation built on May 29, 2017, 4:26 p.m.