Neural Network Toolbox | Search  Help Desk |
learncon | Examples See Also |
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 which have the lowest average output until each neuron responds roughly an equal percentage of the time.
learncon(B,P,Z,N,A,T,E,gW,gA,D,LP,LS)
takes several inputs,
Z - S
x Q
weighted input vectors.
T - S
x Q
layer target vectors.
E - S
x Q
layer error vectors.
gW - S
x R
gradient with respect to performance.
gA - S
x Q
output gradient with respect to performance.
LP -
Learning parameters, none, LP = []
.
LS -
Learning state, initially should be = [].
learncon
's learning parameter, shown here with its default value.
LP.lr - 0.001 -
Learning rate.
learncon(code)
returns useful information for each code
string,
'pnames
' - Names of learning parameters.
'pdefaults
' - Default learning parameters.
'needg
' - Returns 1 if this function uses gW or gA
.
LP.lr
described above equals 1 minus the bias time constant used by trainc
in NNT 2.0.
Here we define a random output A
, and bias vector W
for a layer with 3 neurons. We also define the learning rate LR
.
a = rand(3,1); b = rand(3,1); lp.lr = 0.5;Since
learncon
only needs these values to calculate a bias change (see algorithim below), we will use them to do so.
dW = learncon(b,[],[],[],a,[],[],[],[],[],lp,[])To prepare the bias of layer
i
of a custom network to learn with learncon
:
.net.trainFcn
to 'trainwb1
'. (net.trainParam
will automatically
become adaptwb
's default parameters.)
.net.adaptFcn
to 'adaptwb
'. (net.adaptParam
will automatically become
adaptwb
's default parameters.)
.net.inputWeights{i}.learnFcn
to 'learncon
'. Set each
net.layerWeights{i,j}.learnFcn
to 'learncon
'. (Each weight learning
parameter property will automatically be set to learncon
's default
parameters.)
.net.trainParam
(or net.adaptParam
) properties as desired.
.train
(or adapt
).
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*aThe conscience is then used to compute a bias for the neuron that is greatest for smaller conscience values.
b = exp(1-log(c)) - b(Note that
learncon
is able to recover C
each time it is called from the bias values.)
learnk
,
learnos
,
adaptwb
,
trainwb
,
adapt
,
train