train: Train

Description Usage Arguments Functions Cost functions See Also Examples

Description

Train the brain.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16

Arguments

brain

An object of class brain as returned by brain.

cost

A cost function as returned by cost_function.

log

Frequency at which to log training error and elapsed time (iterations), can be retrieved with get_log.

print

Whether to print training error, iterations and elapsed time.

...

Bare column names from data.

scale

Set to TRUE to scale the data with balance.

data

A data.frame from where to select input and output (...).

rate

Learning rate to train the network. It can be a static rate (just a number), dynamic (an list of numbers, which will transition from one to the next one according to the number of iterations).

iterations

Maximum number of iterations.

error

Minimum error.

shuffle

If TRUE, the training set is shuffled after every iteration, this is useful for training data sequences which order is not meaningful to networks with context memory, like lstm.

cv

Set to TRUE to cross validate.

func

Training cost function, one of cross_entropy, mse (mean squared error), or binary.

Functions

Cost functions

See Also

network to manually create layers, connections and resulting brain, dsr for distracted sequence recall.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
df <- dplyr::tibble(
  x = c(0, 0, 1, 1),
  y = c(0, 1, 0, 1),
  z = c(0, 1, 1, 0)
)

br <- brain() %>%
  perceptron(c(2,3,1)) %>%
  train_data(df) %>%
  train_input(x, y) %>%
  train_output(z) %>%
  train(
    cost = cost_function("cross_entropy"),
    log = 10
  )

log <- get_log(br)
plot(log)

brain-r/brain documentation built on May 21, 2019, 4:05 a.m.