Neural Network Toolbox | Search  Help Desk |
trainbr | Examples See Also |
Bayesian Regulation backpropagation
[net,tr] = trainbr(net,Pd,Tl,Ai,Q,TS,VV)
info = trainbr(code)
trainbr
is a network training function that updates the weight and bias values according to Levenberg-Marquardt optimization. It minimizes a combination of squared errors and weights, and then determines the correct combination so as to produce a network which generalizes well. The process is called Bayesian regularization.
trainbr(net,Pd,Tl,Ai,Q,TS,VV,TV)
takes these inputs,
Ai -
Initial input delay conditions.
VV -
Either empty matrix []
or structure of validation vectors.
TR -
Training record of various values over each epoch:
trainlm
's training parameters, shown here with their default values:
net.trainParam.epochs 100
Maximum number of epochs to train
net.trainParam.goal 0
Performance goal
net.trainParam.mu 0.005
Marquardt adjustment parameter
net.trainParam.mu_dec 0.1
Decrease factor for mu
net.trainParam.mu_inc 10
Increase factor for mu
net.trainParam.mu_max 1e-10
Maximum value for mu
net.trainParam.max_fail 5
Maximum validation failures
Pd - No
x Ni
x TS
cell array, each element P{i,j,ts}
is a Dij
x Q
matrix.
Tl - Nl
x TS
cell array, each element P{i,ts}
is a Vi
x Q
matrix.
Ai - Nl
x LD
cell array, each element Ai{i,k}
is an Si
x Q
matrix.
Dij = Ri * length(net.inputWeights{i,j}.delays)
VV
is not []
, it must be a structure of validation vectors,
VV.PD -
Validation delayed inputs.
VV.Tl -
Validation layer targets.
VV.Ai -
Validation initial input conditions.
VV.TS -
Validation time steps.
max_fail
epochs in a row. This early stopping is not used for trainbr
, but the validation performance is computed for analysis purposes if VV
is not []
.
trainbr(code)
returns useful information for each code
string:
Here is a problem consisting of inputs p and targets t that we would like to solve with a network. It involves fitting a noisy sine wave.
p = [-1:.05:1]; t = sin(2*pi*p)+0.1*randn(size(p));Here a two-layer feed-forward network is created. The network's input ranges from [-1 to 1]. The first layer has 20 tansig neurons, the second layer has one purelin neuron. The trainbr network training function is to be used. The plot of the resulting network output should show a smooth response, without overfitting. Create a Network
net=newff([-1 1],[20,1],{'tansig','purelin'},'trainbr');Train and Test the Network
net.trainParam.epochs = 50; net.trainParam.show = 10; net = train(net,p,t); a = sim(net,p) plot(p,a,p,t,'+')You can create a standard network that uses
trainbr
with newff
, newcf
, or newelm
.
To prepare a custom network to be trained with trainbr
:
.net.trainFcn
to 'trainlm
'. This will set net.trainParam
to trainbr
's
default parameters.
.net.trainParam
properties to desired values.
trainbr
.
See newff
,
newcf
, and newelm
for examples.
trainbr
can train any network as long as its weight, net input, and transfer functions have derivative functions.
Bayesian regularization minimizes a linear combination of squared errors and weights. It also modifies the linear combination so that at the end of training the resulting network has good generalization qualities. See MacKay (Neural Computation, vol. 4, no. 3, 1992, pp. 415-447) and Foresee and Hagan (Proceedings of the International Joint Conference on Neural Networks, June, 1997) for more detailed discussions of Bayesian regularization.
This Bayesian regularization takes place within the Levenberg-Marquardt algorithm. Backpropagation is used to calculate the Jacobian jX
of performance perf
with respect to the weight and bias variables X
. Each variable is adjusted according to Levenberg-Marquardt,
jj = jX * jX je = jX * E dX = -(jj+I*mu) \ jewhere
E
is all errors and I
is the identity matrix.
The adaptive value mu
is increased by mu_inc
until the change shown above results in a reduced performance value. The change is then made to the network and mu
is decreased by mu_dec
.
The parameter mem_reduc
indicates how to use memory and speed to calculate the Jacobian jX
. If mem_reduc
is 1, then trainlm
runs the fastest, but can require a lot of memory. Increase mem_reduc
to 2, cuts some of the memory required by a factor of two, but slows trainlm
somewhat. Higher values continue to decrease the amount of memory needed and increase the training times.
Training stops when any of these conditions occur:
.epochs
(repetitions) is reached.
.time
has been exceeded.
.goal
.
.mingrad
.
.mu
exceeds mu_max
.
.max_fail
times since the
last time it decreased (when using validation).
newff
,
newcf
,
traingdm
,
traingda
,
traingdx
,
trainlm
,
trainrp
,
traincgf
,
traincgb
,
trainscg
,
traincgp
,
trainoss
Foresee, F. D., and M. T. Hagan, "Gauss-Newton approximation to Bayesian regularization," Proceedings of the 1997 International Joint Conference on Neural Networks, 1997.
MacKay, D. J. C., "Bayesian interpolation," Neural Computation, vol. 4, no. 3, pp. 415-447, 1992.