error ??? Index exceeds matrix dimensions.
1 次查看(过去 30 天)
显示 更早的评论
%
--------------------------------------------------------------------------
%define input and output for training
in=d(1:40,1:1000);
ou=d(41:40,1:1000);
trainInput= d(1:40,201:1000); % input for training
trainOutput= d(41:40,201:1000); % output for training
%--------------------------------------------------
% training the MLP Neural network
% newff(input, target,[hidden layer1 hiddenlayer2 output],{transferFunction1 transferFunction2 transferFunction3});
% transferFunction defult for hidden layer is tansig but here use logsig
% and purelin is default transferFunction for output layer
net = newff(minmax(in),ou,[10 10 4],{'logsig' 'logsig' 'purelin'});
%--------------------------------------------------------------------------
% Setting the parameters for training
net.trainParam.epochs = 1000; %set the maximum number of epochs to train
net.trainParam.goal = 0.02; %sum-squared error goal.
%--------------------------------------------------------------------------
% training the MLP by using a a train function
net = train(net,trainInput,trainOutput);
%--------------------------------------------------------------------------
% To draw the result making the testing
testInput=d(1:40,1:200); % extract certain column for testing input
testResult1=sim(net,testInput); % simulate the MLP network by using a sim function
testResult1 = testResult1';
trainOutput2= d(1:40,1:200);
??? Index exceeds matrix dimensions.
above is my code for fold 1 (train set is 201-1000, test set is 1-200) i use dataset 1000x40 double Any expert can u help me...thank you!!!
1 个评论
kjetil87
2013-12-5
I didnt check the entire code but It migh be because of
ou=d(41:40,1:1000);
this is and empty matrix... Correct syntax is
ou=d(41:-1:40,1:1000);
采纳的回答
Greg Heath
2013-12-6
Did it ever occur to you that it is self defeating to include code with a data set that is not accessible to those who want to help you?
In the future try your code on a MATLAB data set before posting. That way you can separate code errors from data errors and get a headstart on receiving focused help.
help nndatasets
doc nndatasets
Either use all of the chosen MATLAB dataset or a subset of it to best match the size of your data.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%define input and output for training
in=d(1:40,1:1000);
ou=d(41:40,1:1000);
'1. ERRONEOUS INDEXING'
trainInput= d(1:40,201:1000); % input for training
trainOutput= d(41:40,201:1000); % output for training
'2.ERRONEOUS INDEXING'
%--------------------------------------------------
% training the MLP Neural network
% newff(input, target,[hidden layer1 hiddenlayer2 output], ...
% {transferFunction1 transferFunction2 transferFunction3});
% transferFunction defult for hidden layer is tansig but here use logsig
% and purelin is default transferFunction for output layer
net = newff(minmax(in),ou,[10 10 4],{'logsig' 'logsig' 'purelin'});
'3. DOUBLY OBSOLETE FUNCTION. USE FITNET.'
'4. ONE HIDDEN LAYER IS SUFFICIENT'
'5. BIPOLAR TANSIG IS BETTER FOR HIDDEN LAYERS THAN UNIPOLAR LOGSIG'
'6. 4 OUTPUT NODES IS ERRONEOUS'
%--------------------------------------------------------------------------
% Setting the parameters for training
net.trainParam.epochs = 1000; %set the maximum number of epochs to train
'7. epochs = 1000 IS A DEFAULT. WHY BOTHER?'
net.trainParam.goal = 0.02; %sum-squared error goal.
'8. WHAT IS THE RATIONALE FOR THIS CHOICE??...(I ASSUME YOU MEANT MSE INSTEAD OF SSE)'
%--------------------------------------------------------------------------
% training the MLP by using a a train function
net = train(net,trainInput,trainOutput);
%--------------------------------------------------------------------------
% To draw the result making the testing
testInput=d(1:40,1:200); % extract certain column for testing input
testResult1=sim(net,testInput); % simulate the MLP network by using a sim function
testResult1 = testResult1';
trainOutput2= d(1:40,1:200);
'9.ERRONEOUS INDEXING'
THANK YOU FOR FORMALLY ACCEPTING MY ANSWER
GREG
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!