shuffle
对数据存储中的所有数据进行乱序处理
说明
示例
无序排列文件
创建 ImageDatastore
对象 imds
。无序排列文件以创建新的数据存储,其中包含按随机顺序排列的相同文件。
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
输入参数
ds
— 输入数据存储
对象
输入数据存储,指定为数据存储对象。输入数据存储可以是 isShuffleable
对其返回 true
的任何数据存储(如 imageDatastore
)。输入数据存储也可以是其所有基础数据存储均可乱序的 CombinedDatastore
、SequentialDatastore
和 TransformedDatastore
。
输出参数
dsrand
— 输出数据存储
对象
输出数据存储,以数据存储对象形式返回,其中包含来自 ds
的随机排序数据。
扩展功能
基于线程的环境
使用 MATLAB® backgroundPool
在后台运行代码或使用 Parallel Computing Toolbox™ ThreadPool
加快代码运行速度。
用法说明和限制:
在基于线程的环境中,您只能对以下数据存储使用
shuffle
:ImageDatastore
对象使用
combine
或transform
从ImageDatastore
对象创建的CombinedDatastore
、SequentialDatastore
或TransformedDatastore
对象
如果您有 Parallel Computing Toolbox™,则可以对其他数据存储使用
shuffle
。为此,请使用基于进程的并行池运行该函数,而不是使用backgroundPool
或ThreadPool
(使用ProcessPool
或ClusterPool
)。
有关详细信息,请参阅在基于线程的环境中运行 MATLAB 函数。
版本历史记录
在 R2016a 中推出
MATLAB 命令
您点击的链接对应于以下 MATLAB 命令:
请在 MATLAB 命令行窗口中直接输入以执行命令。Web 浏览器不支持 MATLAB 命令。
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)