Array of neuralnet structs

1 回表示 (過去 30 日間)
Tiago
Tiago 2011 年 8 月 22 日
Hello everyone,
I'm using Matlab2010a and I do in a loop a several neural networks.
Then I'm trying to save all the neural networks, like above:
for k=1:20
clear cfnet1; clear tr;
cfnet1=newcf(P,T,2,{'tansig' 'tansig'});
cfnet1.trainParam.max_fail = 10;
cfnet1.trainParam.showWindow = 0;
[cfnet1,tr] = train(cfnet1,P,T);
TR(k)=tr;
NET(k)=cfnet1;
end
I can save all the 'tr' in an array, but in case of the neuralnet it is not possible.
Generates an error about arrays and not double values.
??? The following error occurred converting from network to double:
Error using ==> double
Conversion to double from network is not possible.
Did someone try it before ? Is it works in latest versions of Matlab ?

採用された回答

Sean de Wolski
Sean de Wolski 2011 年 8 月 22 日
I think you want TR, NET to be cell arrays or struct arrays?
NET = cell(20,1); %cell arrays
for..
NET{K} = cfnet1
end

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2011 年 8 月 22 日
How exactly are you initializing NET ?

Tiago
Tiago 2011 年 8 月 22 日
Walter, I don' t initialize TR, nor NET. Just to put in a loop the TR array workout. Any array is possible, no needing to initialize. I thought that would workout with the networks array, but it didn't.
---
Sean, I want a array. Whatever it is structs array or cell array. I tried this 'NET = cell(20,1)' but didn't work
??? In an assignment A(:) = B, the number of elements in A and B must be the same.
Matlab tries to insert 20 elements once, not one-by-one.
If change the line "NET(k)=cfnet1;" to "NET(k,:)=cfnet1;" another error occurs: ??? Assignment has more non-singleton rhs dimensions than non-singleton subscripts
if 'NET = cell(20)' the errors is: ??? Subscripted assignment dimension mismatch.
---
This case is more clever than we think. The problem is an array of networks. The type neuralnet is network, not struct nor cell. so I think that we need a network array.
Thanks for all, Tiago
  3 件のコメント
Sean de Wolski
Sean de Wolski 2011 年 8 月 22 日
I'm using braces, you're using parenthesis!
NET{k} is much different than NET(K)
Tiago
Tiago 2011 年 8 月 23 日
Thanks Sean,
that works fine !
Sorry, I didn't read { } braces instead of ( ) parenthesis

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

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by