Classify data using trained deep learning neural network – MATLAB classify

Image data, specified as one of the following.

Data TypeDescriptionExample UsageDatastoreImageDatastoreDatastore of images saved on disk

Make predictions with images saved on disk, where the images are the same
size.

When the images are different sizes, use an
AugmentedImageDatastore object.

AugmentedImageDatastoreDatastore that applies random affine geometric transformations, including
resizing, rotation, reflection, shear, and translation

Make predictions with images saved on disk, where the images are
different sizes.

TransformedDatastoreDatastore that transforms batches of data read from an underlying datastore
using a custom transformation function

  • Transform datastores with outputs not supported by
    classify.

  • Apply custom transformations to datastore output.

CombinedDatastoreDatastore that reads from two or more underlying datastores

  • Make predictions using networks with multiple inputs.

  • Combine predictors from different data sources.

Custom mini-batch datastoreCustom datastore that returns mini-batches of data

Make predictions using data in a format that other datastores do not
support.

For details, see Develop Custom Mini-Batch Datastore.

Numeric arrayImages specified as a numeric arrayMake predictions using data that fits in memory and does not require additional
processing like resizing.TableImages specified as a tableMake predictions using data stored in a table.

When you use a datastore with networks with multiple inputs, the datastore must be a
TransformedDatastore or
CombinedDatastore
object.

Tip

For sequences of images, for example, video data, use the sequences
input argument.

Datastore

Datastores read mini-batches of images and responses. Use datastores when you have data
that does not fit in memory or when you want to resize the input data.

These datastores are directly compatible with classify for image data.:

Note that ImageDatastore objects allow for batch reading of JPG or
PNG image files using prefetching. If you use a custom function for reading the images, then
ImageDatastore objects do not prefetch.

Tip

Use augmentedImageDatastore for efficient preprocessing of images for deep
learning, including image resizing.

Do not use the readFcn option of the imageDatastore
function for preprocessing or resizing, as this option is usually significantly
slower.

You can use other built-in datastores for making predictions by using the transform and
combine
functions. These functions can convert the data read from datastores to the format required
by classify.

The required format of the datastore output depends on the network architecture.

Network ArchitectureDatastore OutputExample OutputSingle input

Table or cell array, where the first column specifies the
predictors.

Table elements must be scalars, row vectors, or 1-by-1
cell arrays containing a numeric array.

Custom datastores must output
tables.

data = read(ds)
data =

  4×1 table

        Predictors    
    __________________

    {224×224×3 double}
    {224×224×3 double}
    {224×224×3 double}
    {224×224×3 double}
data = read(ds)
data =

  4×1 cell array

    {224×224×3 double}
    {224×224×3 double}
    {224×224×3 double}
    {224×224×3 double}

Multiple input

Cell array with at least numInputs columns, where
numInputs is the number of network inputs.

The
first numInputs columns specify the predictors for each
input.

The order of inputs is given by the
InputNames property of the network.

data = read(ds)
data =

  4×2 cell array

    {224×224×3 double}    {128×128×3 double}
    {224×224×3 double}    {128×128×3 double}
    {224×224×3 double}    {128×128×3 double}
    {224×224×3 double}    {128×128×3 double}

The format of the predictors depends on the type of
data.

DataFormat2-D images

h-by-w-by-c
numeric array, where h, w, and
c are the height, width, and number of channels of the
images, respectively

3-D imagesh-by-w-by-d-by-c
numeric array, where h, w,
d, and c are the height, width, depth, and
number of channels of the images, respectively

For more information, see Datastores for Deep Learning.

Numeric Array

For data that fits in memory and does not require additional processing like
augmentation, you can specify a data set of images as a numeric array.

The size and shape of the numeric array depends on the type of image data.

DataFormat2-D images

h-by-w-by-c-by-N
numeric array, where h, w, and
c are the height, width, and number of channels of the
images, respectively, and N is the number of
images

3-D imagesh-by-w-by-d-by-c-by-N
numeric array, where h, w,
d, and c are the height, width, depth, and
number of channels of the images, respectively, and N is the
number of images

Table

As an alternative to datastores or numeric arrays, you can also specify images in a
table.

When you specify images in a table, each row in the table corresponds to an
observation.

For image input, the predictors must be in the first column of the table, specified as
one of the following:

  • Absolute or relative file path to an image, specified as a character vector

  • 1-by-1 cell array containing a
    h-by-w-by-c numeric array
    representing a 2-D image, where h, w, and
    c correspond to the height, width, and number of channels of the
    image, respectively

Tip

To input complex-valued data into a network, the SplitComplexInputs option of the input layer must be 1.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | table
Complex Number Support: Yes