How to read images in the correct order with minibatchqueue?

1 view (last 30 days)
Huhufly on 18 Jan 2022
Answered: yanqi liu on 19 Jan 2022
I was trying to do CNN predictions using a customely trained dlnetwork. While I was trying to feed minibatch data to the network using minibatchqueue for prediction, I found that the image index of the first and the next minibatch was not sequential. Does anyone know how to read data with minibatchqueue object in a correct order?
  1 Comment
Tomaso Cetto
Tomaso Cetto on 18 Jan 2022
Hi there!
The order in which minibatchqueue returns images is most often dependent on the nature of the underlying datastore. By default minibatchqueue will return mini-batches in the same order as the datastore "read" outputs. What datastore are you using? It might be that the datastore is shuffling its data every time it reads it out. It might also be that there is a call to shuffle(minibatchqueue) somewhere in your code.
Another thing which could affect the order in which the images are read out is the use of the DispatchInBackground option of the minibatchqueue object. It's better not to use this option in this case.
Let me know if any of this applies to your case!

Sign in to comment.

Answers (1)

yanqi liu
yanqi liu on 19 Jan 2022
yes,sir,may be set trainingOptions,such as
'Shuffle', 'never'
to make it do not shuffle data order,in common,we offen use
to make train more stable

Community Treasure Hunt

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

Start Hunting!

Translated by