shuffle
Shuffle all data in datastore
Syntax
Description
Examples
Shuffle Files
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 = shuffle(imds)
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
ds
— Input datastore
object
Input datastore, specified as a datastore object. The input datastore can
be any datastore for which isShuffleable
returns true
(such as
imageDatastore
). The input
datastore also can be a CombinedDatastore
, SequentialDatastore
, or TransformedDatastore
for which all underlying datastores are
shuffleable.
Output Arguments
dsrand
— Output datastore
object
Output datastore, returned as a datastore object containing randomly
ordered data from ds
.
Extended Capabilities
Thread-Based Environment
Run code in the background using MATLAB® backgroundPool
or accelerate code with Parallel Computing Toolbox™ ThreadPool
.
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 use
shuffle
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
See Also
ImageDatastore
| datastore
| isShuffleable
| matlab.io.Datastore
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)