This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.


Conscience bias learning function


[dB,LS] = learncon(B,P,Z,N,A,T,E,gW,gA,D,LP,LS)
info = learncon('code')


learncon is the conscience bias learning function used to increase the net input to neurons that have the lowest average output until each neuron responds approximately an equal percentage of the time.

[dB,LS] = learncon(B,P,Z,N,A,T,E,gW,gA,D,LP,LS) takes several inputs,


S-by-1 bias vector


1-by-Q ones vector


S-by-Q weighted input vectors


S-by-Q net input vectors


S-by-Q output vectors


S-by-Q layer target vectors


S-by-Q layer error vectors


S-by-R gradient with respect to performance


S-by-Q output gradient with respect to performance


S-by-S neuron distances


Learning parameters, none, LP = []


Learning state, initially should be = []

and returns


S-by-1 weight (or bias) change matrix


New learning state

Learning occurs according to learncon's learning parameter, shown here with its default value. - 0.001

Learning rate

info = learncon('code') returns useful information for each supported code string:


Names of learning parameters


Default learning parameters


Returns 1 if this function uses gW or gA

Neural Network Toolbox™ 2.0 compatibility: The described above equals 1 minus the bias time constant used by trainc in the Neural Network Toolbox 2.0 software.


Here you define a random output A and bias vector W for a layer with three neurons. You also define the learning rate LR.

a = rand(3,1);
b = rand(3,1); = 0.5;

Because learncon only needs these values to calculate a bias change (see "Algorithm" below), use them to do so.

dW = learncon(b,[],[],[],a,[],[],[],[],[],lp,[])

Network Use

To prepare the bias of layer i of a custom network to learn with learncon,

  1. Set net.trainFcn to 'trainr'. (net.trainParam automatically becomes trainr's default parameters.)

  2. Set net.adaptFcn to 'trains'. (net.adaptParam automatically becomes trains's default parameters.)

  3. Set net.inputWeights{i}.learnFcn to 'learncon'

  4. Set each net.layerWeights{i,j}.learnFcn to 'learncon'. .(Each weight learning parameter property is automatically set to learncon's default parameters.)

To train the network (or enable it to adapt),

  1. Set net.trainParam (or net.adaptParam) properties as desired.

  2. Call train (or adapt).

More About

collapse all


learncon calculates the bias change db for a given neuron by first updating each neuron's conscience, i.e., the running average of its output:

c = (1-lr)*c + lr*a

The conscience is then used to compute a bias for the neuron that is greatest for smaller conscience values.

b = exp(1-log(c)) - b

(learncon recovers C from the bias values each time it is called.)

See Also

| | |

Introduced before R2006a

Was this topic helpful?