Index must be a positive integer less than or equal to the number of test sets.
2 views (last 30 days)
Show older comments
Hi
i'm trying to create 10-fold cross validation for my CNN. To create the 10 batches I'm using a for loop, but it's giving this error again and again.
'Index must be a positive integer less than or equal to the number of test sets.'
Possibly how I can change the loop to initialize batches.?
selectBatch=cell(1,10);
for k=1:10
%%Prep Data
% 10 kfold crossvalidation indicies
c = cvpartition(204,'kfold',10);
testInd = test(c,selectBatch(k));
trainInd = ~testInd;
epochsTarget = zeros(204,1);
epochsTarget(103:end)=1;
epochsTarget= categorical(epochsTarget);
...............
end
3 Comments
Image Analyst
on 11 Dec 2019
The error message says your line of code throwing the error is
testIndices = test(cv.Impl,varargin{:});
not
testInd = test(c,selectBatch(k));
When you set a breakpoint on line 229 of your program, what are the values of cv.Impl and varargin{:}? Why are you sending in varargin anyway???
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!