Anny on

Class: Trainer

Trainer

A Trainer teaches a Network how to correctly classify some data.

Constructor

new Trainer(optionsopt)

Parameters:
Name Type Attributes Description
options object <optional>
Properties
Name Type Attributes Default Description
batch boolean | number <optional>

Use batch, online (stochastic), or mini-batch learning modes.

Batch true: Connection weights are updated once after iterating through all the training samples in the training data (an epoch).

Online false: Connection weights are updated after every training sample in the training data.

Mini-batch <number>: Connection weights are updated every <number> training samples.

errorThreshold number <optional>
0.001

The target error value. The goal of the Trainer is to train the Network until the error is below this value.

frequency number <optional>
100

How many iterations through the training data between calling options.onProgress.

maxEpochs number <optional>
20000

The max training iterations. The Trainer will stop training after iterating through the training data this number of times. One full loop through the training data is counted as one epoch.

onFail Trainer~onFail <optional>

Called if the Network error does not fall below the errorThreshold after maxEpochs.

onProgress Trainer~onProgress <optional>

Called every frequency epochs.

onSuccess Trainer~onSuccess <optional>

Called if the Network error falls below the errorThreshold during training.

Source:
Example
const network = new anny.Network([2, 1])
const trainer = new Trainer()

trainer.train(network, anny.DATA.ORGate)

network.activate([0, 0]) // => 0.000836743108
network.activate([0, 1]) // => 0.998253857294

Methods

train(network, data, overridesopt)

Train the network to classify the data.

Train the network to classify the data.

Parameters:
Name Type Attributes Description
network Network

The Network to be trained.

data Array.<object>

Array of objects in the form {input: [], output: []}.

overrides Object <optional>

Overrides are merged into this trainer

Properties
Name Type Attributes Description
onSuccess Trainer~onSuccess <optional>

Overrides are merged into this trainer instance's options.

Source:
See:

Type Definitions

onFail(error, epoch)

Called if the network error is not below the errorThreshold after maxEpochs iterations through the training data set.

Called if the network error is not below the errorThreshold after maxEpochs iterations through the training data set.

Parameters:
Name Type Description
error number

The network error value at the time of success.

epoch number

Indicates on which iteration through the training data the network became successful.

Source:

onProgress(error, epoch)

Called if the network error falls below the errorThreshold.

Called if the network error falls below the errorThreshold.

Parameters:
Name Type Description
error number

The network error value at the time of success.

epoch number

Indicates on which iteration through the training data the network became successful.

Source:

onSuccess(error, epoch)

Called if the network error falls below the errorThreshold.

Called if the network error falls below the errorThreshold.

Parameters:
Name Type Description
error number

The network error value at the time of success.

epoch number

Indicates on which iteration through the training data the network became successful.

Source: