How would I access the weights of a trained neural network?

I have a 2 layered neural network. I vary the No. of hidden(H) neuron form 1 to 10. Each network undergoes 10 trials(n). I calculate R2(n,H) and R2a(n,H). I would like to get the weight and bias values of the network that which has the smallest R2a. Is it possible? thanks in advance.

 Accepted Answer

1. Before the double loop initialize your RNG (e.g., rng(0) ). From this you can deduce the state of the RNG before loop (nopt,Hopt). Therefore, you can recreate netopt.
2. However, this is much better:
a. initialize bestR2a = 0
b. whenever R2a > bestR2a, save n, H, and getwb(net)
c. You could save all of the n*H results or overwrite each previous choice and end up with only the final result.
3. Unless you are using dividetrain, the best net is usually chosen from the validation set performance and the best UNBIASED performance estimate on unseen data is obtained by the test set performance on the best net determined by the validation set.
4. I have noticed that many times in plots of R2 vs H for
a. Maximum R2a designs
b. Maximum R2val designs
that
(R2trn+R2trna)/2 ~ (R2val+R2tst)/2
However, I'm not sure what to do with that info.
Hope this helps.
Thank you for formally accepting my answer
Greg

More Answers (0)

Categories

Find more on Deep Learning Toolbox in Help Center and File Exchange

Asked:

on 7 Feb 2014

Edited:

on 12 Feb 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!