How to save workspace in a for loop?

Hello,
I want to save the workspace at each iteration (in a vector maybe). By doing this, I will be able to reach any workspace generated at any iteration.
Thank you.

3 件のコメント

Geoff Hayes
Geoff Hayes 2014 年 11 月 17 日
Ibra - when you say that you want to save the workspace at each iteration do you mean that you want to save a particular variable or all variables at that iteration (like a snapshot)? Please provide more details concerning the variables. Depending upon how many there are, you may want to save all to a file or save all to a structure (which gets saved to an array/vector).
ibra
ibra 2014 年 11 月 18 日
Hello Geoff,
To be more specific, I'm training a Neural Network. I want to train it for several times within a for loop and find out which network structure gives the lowest error. Therefore, I can say that I want to save the whole variables in the workspace at each iteration.
Thank you.
Image Analyst
Image Analyst 2014 年 11 月 18 日
Just have the variables be arrays. Assign the value to an array with the same index as the loop index (if it's sequential integers).

サインインしてコメントする。

 採用された回答

Greg Heath
Greg Heath 2014 年 11 月 18 日

2 投票

Typically I design 100 nets at a time using a double loop: 10 values of hidden nodes: h = Hmin:dH:Hmax and 10 random initial weight assignments ntrial = 1:Ntrials for each value of h.
Instead of saving all of the nets, just save h, the state of the random number generator s(rng) and the corresponding performance measure (NMSE or Rsquared = 1-NMSE) for each design. Afterwards the values of h and s for the smallest NMSE are retrieved and the best net can be retrained.
Better yet, alternatively start with the first net as the best net. Then each time a new design is better, that becomes the best net. Consequently, only one net needs to be saved at any time.
If you wish, you could modify the last approach to save the best 10 (or whatever) nets.
I have posted many, many designs using the first approach. Unfortunately, I have posted at most, a few designs using the best saved net.
I will search for the latter and post the URLs.
The first approach designs are reasdily found by searching
greg i=1:Ntrials h=Hmin:dH:Hmax (or h = 0:dH:Hmax)
Hope this helps.
Thank you for formally accepting my answer
Greg

1 件のコメント

Greg Heath
Greg Heath 2014 年 11 月 18 日
NN accuracy on test set low Asked by Anitha on 12 Mar 2014 http://www.mathworks.com/matlabcentral/answers/121234-nn-accuracy-on-test-set-low =============================================================================
Subject: DUPLICATING THE BEST NEURAL NET DESIGN From: Greg Heath Date: 18 Mar, 2014 http://www.mathworks.com/matlabcentral/newsreader/view_thread/334932#919949

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2014 年 11 月 17 日

コメント済み:

2014 年 11 月 18 日

Community Treasure Hunt

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

Start Hunting!

Translated by