How to split dataset of 3300 image into Training and Testing Datasets?

I am workin on face Recognition system using CNN, I have 3300 human face images how can I split them in to Training and testing dataset using this deep leaning function [TrainData,TestData] = SplitEachLabel. I want to have 1843 traing data and 1457 testing data. I need your Assistance.

답변 (1개)

Tejas
Tejas 2025년 7월 9일
Hello Sanusi,
To split the image dataset, the recommend approach is to store the images using the "imageDatastore" function and use the "splitEachLabel" function to split the images.
Here are steps to acheive the desired worflow:
  • Load the images using the "imageDatastore" function.
imds = imageDatastore(rootFolder, 'IncludeSubfolders', true, 'LabelSource', 'foldernames');
  • Find the percentage of images to be split into training dataset.
totalImages = numel(imds.Files);
numTrain = 1843;
numTest = 1457;
trainFraction = numTrain / totalImages;
  • Use the "splitEachLabel" function to split the image dataset.
[TrainData, TestData] = splitEachLabel(imds, trainFraction, 'randomized');
For more examples on how the image dataset can be split, refer to this documentation: https://www.mathworks.com/help/matlab/ref/matlab.io.datastore.imagedatastore.spliteachlabel.html#bu48dhj-1-p .

카테고리

도움말 센터File Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

제품

릴리스

R12.1

태그

질문:

2021년 5월 9일

답변:

2025년 7월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by