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.

Respuestas (1)

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 .

Categorías

Más información sobre Deep Learning Toolbox en Centro de ayuda y File Exchange.

Productos

Versión

R12.1

Etiquetas

Preguntada:

el 9 de Mayo de 2021

Respondida:

el 9 de Jul. de 2025

Community Treasure Hunt

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

Start Hunting!

Translated by