Combine multiple datastores in for loop for Leave one out cross validation

I have 30 imagedatastores stored in a cell arrays bigImgDS{30,1}.
Now I want select one datastore in cell array as test and combine all other as train in one iteration of loop. But it doesnt allow me to do that
N = numel(bigImgDS)
for i =1:N
test = Big_ImgDs{i,1};
train = Big_ImgDs{[1:end ~=i],1}
end

Answers (1)

Hi Mudit,
Use the following code for looping in the cell array
for i =1:N
test = Big_ImgDs{i};
train = Big_ImgDs;
train(i)=[];
end
Regards,
Anmol Dhiman

3 Comments

Thank you Anmol for this answer.
But if i do this the Big_ImgDs which is stored in the train set is still a cell array of all the image datastores except the test set. It does not act as a signle datastore by the combination of all the datastore in that cell array.
I want to combine the rest of the image datastores except the test datastore as a single image datastore not combined imagedatastore . This is due to the fact that the combined datastore does not follow the same properties of the single image datastore such as the function 'spliteachlabel' for further injecting it into the deep learning network
I tried that out Anmol. But Split ImageDatastore labels by proportions - MATLAB splitEachLabel (mathworks.com) doesnt work on combine. Thats the problem the combine datastore doesnt behave the same way as a Image datastore

Sign in to comment.

Asked:

on 5 Dec 2020

Commented:

on 10 Dec 2020

Community Treasure Hunt

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

Start Hunting!