Main Content


Cyclical order weight/bias training


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


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

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

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

trainc trains a network with weight and bias learning rules with incremental updates after each presentation of an input. Inputs are presented in cyclic order.

Training occurs according to trainc training parameters, shown here with their default values:


Maximum number of epochs to train


Performance goal


Maximum validation failures


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 trainc by calling competlayer. To prepare a custom network to be trained with trainc,

  1. Set net.trainFcn to 'trainc'. This sets net.trainParam to trainc’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.

See perceptron for training examples.


For each epoch, each vector (or sequence) is presented in order to the network, with the weight and bias values updated accordingly after each individual presentation.

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.

Version History

Introduced before R2006a

See Also