shuffle and partition in training, validation and testing of a multi-label combined dataset

3 views (last 30 days)
I want to train a Faster R-CNN with 224x224x3 images that are log-scaled mel spectrograms from the UrbanSound8k dataset
The data is already labeled with rectangles.
here's my code:
%% imds* are M x 2 tables, 1st column 'imageFileName' 2nd 'label_name' with [x,y,height,width] of the rectangular ROIs
%% Dataset Extraction: Label tables combining
airConditionerLbl = imdsAirConditioner(:,2:end);
carHornLbl = imdsCarHorn(:,2:end);
childrenPlayingLbl = imdsChildrenPlaying(:,2:end);
dogBarkLbl = imdsDogBark(:,2:end);
drillingLbl = imdsDrilling(:,2:end);
engineIdlingLbl = imdsEngineIdling(:,2:end);
gunShotLbl = imdsGunShot(:,2:end);
jackhammerLbl = imdsJackhammer(:,2:end);
sirenLbl = imdsSiren(:,2:end);
streetMusicLbl = imdsStreetMusic(:,2:end);
%% Combining into boxLabelDs
blds = boxLabelDatastore(airConditionerLbl,carHornLbl,childrenPlayingLbl,dogBarkLbl,drillingLbl,engineIdlingLbl,gunShotLbl,jackhammerLbl,sirenLbl,streetMusicLbl);
%% extract imagesFileName from tables
airConditionerFiles = imdsAirConditioner.imageFilename;
carHornFiles = imdsCarHorn.imageFilename;
childrenPlayingFiles = imdsChildrenPlaying.imageFilename;
dogBarkFiles = imdsDogBark.imageFilename;
drillingFiles = imdsDrilling.imageFilename;
engineIdlingFiles = imdsEngineIdling.imageFilename;
gunShotFiles = imdsGunShot.imageFilename;
jackhammerFiles = imdsJackhammer.imageFilename;
sirenFiles = imdsSiren.imageFilename;
streetMusicFiles = imdsStreetMusic.imageFilename;
%% create the imageDatastore
imds = imageDatastore([airConditionerFiles;carHornFiles;childrenPlayingFiles;dogBarkFiles;drillingFiles;engineIdlingFiles;gunShotFiles;jackhammerFiles;sirenFiles;streetMusicFiles]);
%% combine the datastores
cds = combineDatastore(imds,blds);
I want to shuffle and split the data into training, validation and testing and I don't know how and where I can do it in this code.
Can anyone help me?
Thank you.

Answers (2)

Claudio Eutizi
Claudio Eutizi on 18 Jan 2021
Edited: Claudio Eutizi on 18 Jan 2021
Can anybody help me with this?

Srivardhan Gadila
Srivardhan Gadila on 30 Jan 2021
You can refer to the documentation of the functions partition & shuffle. For the list of other functions supported by the CombinedDatastore object you can refer to Object Functions of the CombinedDatastore.

Categories

Find more on Image Data Workflows in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!