The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: ga optimization of nn weights
Replies: 5   Last Post: Feb 8, 2013 9:47 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Greg Heath

Posts: 6,387
Registered: 12/7/04
Re: ga optimization of nn weights
Posted: Feb 6, 2013 8:24 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

> function mse_calc = mse_test(x, net, inputs, targets)
> % 'x' contains the weights and biases vector
> % in row vector form as passed to it by the
> % genetic algorithm. This must be transposed
> % when being set as the weights and biases
> % vector for the network.
> % To set the weights and biases vector to the
> % one given as input
> net = setwb(net, x);
> % To evaluate the ouputs based on the given
> % weights and biases vector
> y = net(inputs);
> % Calculating the mean squared error
> mse_calc = sum((y-targets).^2)/length(y);

No. This is only valid for vectors. For matrices
there are many equivalent forms

Neq = prod(size(targets))
e = targets - y;

MSE = sum(sum(e.^2))/Neq
MSE = sumsqr(e)/Neq
MSE = sse(e)/Neq
MSE = mse(e)

There are several ways to mitigate overfitting,

1. Reduce H so that Neq >>Nw. An adequate value of r = Neq/Nw depends on the data.
2. Adjust MSE above by replacing Neq with Ndof = Neq - Nw, the number of degrees of freedom for estimation.
3. Use a holdout (from training) validation subset to stop the minimization of MSEtrn when MSEval is a minimum.
4. Use regularization with the modified MSE

MSEreg = MSE + alpha*mse(x)

I don't remember how alpha is determined. Check the source codes of msereg and
trainbr; e.g.,

help msereg
doc msereg
type msereg

Hope this helps.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.