shuffle - Shuffle all data in datastore - MATLAB (original) (raw)
Main Content
Shuffle all data in datastore
Syntax
Description
[dsrand](#bu4%5Fff9-1-imdsrand) = shuffle([ds](#bu4%5Fff9-1-imds))
returns a datastore object containing a random ordering of the data fromds
.
Examples
Create an ImageDatastore
object imds
. Shuffle the files to create a new datastore containing the same files in random order.
imds = imageDatastore(fullfile(matlabroot, 'toolbox', 'matlab', {'demos','imagesci'}),'LabelSource','foldernames','FileExtensions', {'.jpg', '.png', '.tif'})
imds =
ImageDatastore with properties:
Files: {
' ...\matlab\toolbox\matlab\demos\cloudCombined.jpg';
' ...\matlab\toolbox\matlab\demos\example.tif';
' ...\matlab\toolbox\matlab\demos\landOcean.jpg'
... and 5 more
}
Labels: [demos; demos; demos ... and 5 more categorical]
ReadFcn: @readDatastoreImage
imdsrand =
ImageDatastore with properties:
Files: {
' ...\matlab\toolbox\matlab\demos\street2.jpg';
' ...\matlab\toolbox\matlab\demos\landOcean.jpg';
' ...\matlab\toolbox\matlab\imagesci\corn.tif'
... and 5 more
}
Labels: [demos; demos; imagesci ... and 5 more categorical]
ReadFcn: @readDatastoreImage
Input Arguments
Output Arguments
Output datastore, returned as a datastore object containing randomly ordered data from ds
.
Extended Capabilities
Usage notes and limitations:
- In a thread-based environment, you can use
shuffle
only with the following datastores:ImageDatastore
objectsCombinedDatastore
,SequentialDatastore
, orTransformedDatastore
objects you create fromImageDatastore
objects by usingcombine
ortransform
You can useshuffle
with other datastores if you have Parallel Computing Toolbox™. To do so, run the function using a process-backed parallel pool instead of usingbackgroundPool
orThreadPool
(use eitherProcessPool
orClusterPool
).
For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced in R2016a