Main Content

reset

Reset minibatchqueue to start of data

    Description

    reset(mbq) resets mbq back to the start of the underlying datastore.

    Examples

    collapse all

    You can call next on a minibatchqueue until all data is returned. When you reach the end of the data, use reset to reset the minibatchqueue and continue obtaining mini-batches with next.

    Create a minibatchqueue from a datastore.

    ds = digitDatastore;
    mbq = minibatchqueue(ds,'MinibatchSize',256)
    mbq = 
    minibatchqueue with 1 output and properties:
    
       Mini-batch creation:
               MiniBatchSize: 256
            PartialMiniBatch: 'return'
                MiniBatchFcn: 'collate'
        DispatchInBackground: 0
    
       Outputs:
                  OutputCast: {'single'}
             OutputAsDlarray: 1
             MiniBatchFormat: {''}
           OutputEnvironment: {'auto'}
    

    Iterate over all data in the minibatchqueue. Use hasdata to check if data is still available.

    while hasdata(mbq)
        [~] = next(mbq);
    end

    When hasdata returns false, you cannot collect a mini-batch using next.

    hasdata(mbq)
    ans = 
       0
    X = next(mbq);
    Error using minibatchqueue/next (line 353)
    Unable to provide a mini-batch because end of data reached. Use reset or shuffle to continue generating mini-batches from the data set.

    Reset the minibatchqueue. Now, hasdata returns true, and you can continue to obtain data using next.

    reset(mbq);
    hasdata(mbq)
    ans = 
       1
    
    X = next(mbq);

    Input Arguments

    collapse all

    Queue of mini-batches, specified as a minibatchqueue object.

    Introduced in R2020b