Batch training with weight and bias learning rules


net.trainFcn = 'trainb'
[net,tr] = train(net,...)


trainb is not called directly. Instead it is called by train for networks whose net.trainFcn property is set to 'trainb', thus:

net.trainFcn = 'trainb' sets the network trainFcn property.

[net,tr] = train(net,...) trains the network with trainb.

trainb trains a network with weight and bias learning rules with batch updates. The weights and biases are updated at the end of an entire pass through the input data.

Training occurs according to trainb's training parameters, shown here with their default values:


Maximum number of epochs to train


Performance goal


Maximum validation failures

net.trainParam.min_grad1e-6Minimum performance gradient

Epochs between displays (NaN for no displays)


Generate command-line output


Show training GUI


Maximum time to train in seconds

Network Use

You can create a standard network that uses trainb by calling linearlayer.

To prepare a custom network to be trained with trainb,

  1. Set net.trainFcn to 'trainb'. This sets net.trainParam to trainb's default parameters.

  2. Set each net.inputWeights{i,j}.learnFcn to a learning function. Set each net.layerWeights{i,j}.learnFcn to a learning function. Set each net.biases{i}.learnFcn to a learning function. (Weight and bias learning parameters are automatically set to default values for the given learning function.)

To train the network,

  1. Set net.trainParam properties to desired values.

  2. Set weight and bias learning parameters to desired values.

  3. Call train.

More About

expand all


Each weight and bias is updated according to its learning function after each epoch (one pass through the entire set of input vectors).

Training stops when any of these conditions is met:

  • The maximum number of epochs (repetitions) is reached.

  • Performance is minimized to the goal.

  • The maximum amount of time is exceeded.

  • Validation performance has increased more than max_fail times since the last time it decreased (when using validation).

See Also


Was this topic helpful?