Main Content

next

Obtain next mini-batch of data from minibatchqueue

Since R2020b

    Description

    [x1,...,xN] = next(mbq) returns a mini-batch of data prepared using the minibatchqueue object mbq. The function returns as many variables as the number of outputs of mbq.

    Examples

    collapse all

    Create a minibatchqueue object and obtain a mini-batch.

    Create a minibatchqueue object from a datastore. Set the MiniBatchSize property to 2.

    auimds = augmentedImageDatastore([100 100],digitDatastore);
    mbq = minibatchqueue(auimds,MiniBatchSize=2,MiniBatchFormat={'SSBC','BC'})
    mbq = 
    minibatchqueue with 2 outputs and properties:
    
       Mini-batch creation:
                   MiniBatchSize: 2
                PartialMiniBatch: 'return'
                    MiniBatchFcn: 'collate'
        PreprocessingEnvironment: 'serial'
    
       Outputs:
                      OutputCast: {'single'  'single'}
                 OutputAsDlarray: [1 1]
                 MiniBatchFormat: {'SSBC'  'BC'}
               OutputEnvironment: {'auto'  'auto'}
    

    Use next to obtain a mini-batch. mbq has two outputs.

    [X,Y] = next(mbq);

    X is a mini-batch containing two images from the datastore. Y contains the classification labels of those images. Check the size and data format of the mini-batch variables.

    size(X)
    dims(X)
    size(Y)
    dims(Y)
    ans = 1×4    
       100   100     1     2
    ans = 'SSCB'
    ans = 1×2    
         1     2
    ans = 'CB'

    Input Arguments

    collapse all

    Mini-batch queue, specified as a minibatchqueue object.

    Output Arguments

    collapse all

    Mini-batch, returned as a numeric array or cell array.

    The number and type of variables returned by next depends on the configuration of mbq. The function returns as many variables as the number of outputs of mbq.

    Version History

    Introduced in R2020b