isShuffleable
データストアがシャッフル可能かどうかを判別
説明
tf = isShuffleable(
は、データストア ds
)ds
がシャッフル可能な場合は logical 1
(true
) を返します。それ以外の場合、結果は logical 0
(false
) です。
TransformedDatastore
は、基となるすべてのデータストアがシャッフル可能な場合にシャッフルできます。CombinedDatastore
は、基となるすべてのデータストアがsubset
メソッドをもつか、subset
メソッドをもつデータストアを変換または統合したものである場合にシャッフルできます。カスタム データストア クラスは、
matlab.io.datastore.Shuffleable
からサブクラス化される場合にシャッフルできます。
シャッフル可能なデータストアに対して関数 shuffle
を使用すると、異なるデータストアでファイルの行関連付けを維持しながら、ファイルの順序をランダム化できます。
例
データストアがシャッフル可能かどうかをテスト
ImageDatastore
を作成し、シャッフル可能な場合にのみデータストアをシャッフルする if/else
ステートメントを記述します。
imageFiles = {'street1.jpg','street2.jpg','peppers.png','corn.tif'}; imds = imageDatastore(imageFiles); if isShuffleable(imds) newds = shuffle(imds); disp('Shuffling successful.') else disp('Datastore is not shuffleable.') end
Shuffling successful.
次に、imds
の 2 つのコピーで構成される CombinedDatastore
オブジェクトを作成します。同じ if/else
テストを使用してデータストアをシャッフルします。
cds = combine(imds,imds); if isShuffleable(cds) newds = shuffle(cds); disp('Shuffling successful.') else disp('Datastore is not shuffleable.') end
Shuffling successful.
この場合、基となる ImageDatastore
オブジェクトが subset
メソッドをもつため、統合データストア cds
はシャッフルできます。
別の CombinedDatastore
オブジェクトを作成しますが、今回は TabularTextDatastore
オブジェクトから作成します。この場合、基となる TabularTextDatastore
オブジェクトが subset
メソッドをもたないため、統合データストアはシャッフルできません。
ttds = tabularTextDatastore('outages.csv'); cds = combine(ttds,ttds); if isShuffleable(cds) newds = shuffle(cds); disp('Shuffling successful.') else disp('Datastore is not shuffleable.') end
Datastore is not shuffleable.
入力引数
ds
— 入力データ ストア
データ ストア
入力データ ストア。次のデータストアを入力として使用できます。
MATLAB® データ ストア — MATLAB
datastore
関数を使用して作成されたデータ ストア。たとえば、ImageDatastore
を使用して、イメージの集合用のデータ ストアを作成します。データ ストアの完全な一覧は、ファイル形式またはアプリケーション用のデータ ストアの選択を参照してください。統合および変換を行ったデータ ストア — 関数
combine
およびtransform
を使用して作成したデータ ストア。カスタム データ ストア — カスタム データ ストア フレームワークを使用して作成したデータ ストア。
matlab.io.Datastore
からサブクラス化されるデータストアで関数isShuffleable
がサポートされます。詳細については、カスタム データ ストアの開発を参照してください。
拡張機能
スレッドベースの環境
MATLAB® backgroundPool
を使用してバックグラウンドでコードを実行するか、Parallel Computing Toolbox™ のThreadPool
を使用してコードを高速化します。
使用上の注意事項および制限事項:
スレッドベースの環境では、次のデータストアでのみ
isShuffleable
を使用できます。ImageDatastore
オブジェクトcombine
またはtransform
を使用してImageDatastore
オブジェクトから作成するCombinedDatastore
またはTransformedDatastore
オブジェクト
Parallel Computing Toolbox™ がある場合は、他のデータストアで
isShuffleable
を使用できます。これを行うには、backgroundPool
またはThreadPool
を使用する代わりに、プロセスベースの並列プールを使用して関数を実行します (ProcessPool
またはClusterPool
を使用します)。
詳細については、Run MATLAB Functions in Thread-Based Environmentを参照してください。
バージョン履歴
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)