Array of neuralnet structs

조회 수: 3 (최근 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 CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by