Classify data using a trained deep learning neural network
Deep Learning Toolbox / Deep Neural Networks
The Image Classifier block predicts class labels for the data at the input by using the trained network specified through the block parameter. This block allows loading of a pretrained network into the Simulink® model from a MAT-file or from a MATLAB® function.
Note
The Image Classifier block does not support sequence networks and multiple input and multiple output networks (MIMO).
image
— Image dataA
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. If the array contains
NaN
s, then they are propagated through the network.
ypred
— Predicted class labelsPredicted class labels with the highest score, returned as a N-by-1 enumerated vector of labels, where N is the number of observations.
scores
— Predicted class scoresPredicted scores, returned as a N-by-K matrix, where N is the number of observations, and K is the number of classes.
labels
— Class labels for predicted scoresLabels associated with the predicted scores, returned as a N-by-K matrix, where N is the number of observations, and K is the number of classes.
Network
— Source for trained networkNetwork from MAT-file
(default) | Network from MATLAB function
| squeezenet
Specify the source for the trained network. Select one of the following:
Network from MAT-file
— Import a trained
network from a MAT-file containing a SeriesNetwork
or a DAGNetwork
object.
Network from MATLAB function
— Import a
pretrained network from a MATLAB function. For example, by using the
googlenet
function.
File path
— MAT-file containing trained network This parameter specifies the name of the MAT-file that contains the trained deep learning network to load. If the file is not on the MATLAB path, use the Browse button to locate the file.
To enable this parameter, set the Network parameter to
Network from MAT-file
.
MATLAB function
— MATLAB function nameThis parameter specifies the name of the MATLAB function for the pretrained deep
learning network. For example, use googlenet
function to import the
pretrained GoogLeNet model.
To enable this parameter, set the Network parameter to
Network from MATLAB function
.
Mini-batch size
— Size of mini-batchesSize of mini-batches to use for prediction, specified as a positive integer. Larger mini-batch sizes require more memory, but can lead to faster predictions.
Resize input
— Resize the input dimensionsResize the data at the input port to the input size of the network.
Classification
— Output predicted label with highest scoreEnable output port ypred
that outputs the label with the
highest score.
Predictions
— Output all scores and associated labelsEnable output ports scores
and labels
that
output all predicted scores and associated class labels.
Usage notes and limitations:
The Language parameter in the Configuration
Parameters > Code Generation general category must
be set to C++
.
For ERT-based targets, the Support: variable-size signals parameter in the Code Generation> Interface pane must be enabled.
For a list of networks and layers supported for code generation, see Networks and Layers Supported for C++ Code Generation (MATLAB Coder).
Usage notes and limitations:
The Language parameter in the Configuration
Parameters > Code Generation general category must
be set to C++
.
For a list of networks and layers supported for CUDA® code generation, see Supported Networks and Layers (GPU Coder).
To learn more about generating code for Simulink models containing the Image Classifier block, see Code Generation for a Deep Learning Simulink Model to Classify ECG Signals (GPU Coder).