In Deep Learning Toolbox™, you can define network architectures with multiple inputs (for example, networks trained on multiple sources and types of data) or multiple outputs (for example, networks that predicts both classification and regression responses).
Define networks with multiple inputs when the network requires data from multiple sources or in different formats. For example, networks that require image data captured from multiple sensors at different resolutions.
To define and train a deep learning network with multiple inputs, specify the
network architecture using a layerGraph
object and train using the
trainNetwork
function by specifying the multiple inputs
using a combinedDatastore
or transformedDatastore
object.
For networks with multiple inputs, the datastore must be a
combined or transformed datastore that returns a cell array with
(numInputs
+1) columns containing the predictors and the responses, where
numInputs
is the number of network inputs and
numResponses
is the number of responses. For i
less
than or equal to numInputs
, the i
th element of the cell
array corresponds to the input layers.InputNames(i)
, where
layers
is the layer graph defining the network architecture. The last
column of the cell array corresponds to the responses.
If the network also has multiple outputs, then you must define the network as a function and train the network using a custom training loop. for more information, see Multiple-Output Networks.
To make predictions on a trained deep learning network with multiple inputs, use
either the predict
or classify
functions and specify the multiple inputs using a
combinedDatastore
or transformedDatastore
object.
Define networks with multiple outputs for tasks requiring multiple responses in different formats. For example, tasks requiring both categorical and numeric output.
To train a deep learning network with multiple outputs, define the network as a function and train it using a custom training loop. For an example, see Train Network with Multiple Outputs.
To make predictions using a model function, use the model function directly with the trained parameters. For an example, see Make Predictions Using Model Function.
Alternatively, convert the model function to a DAGNetwork
object
using the functionToLayerGraph
and assembleNetwork
functions. With the assembled network, you can use the predict
function for DAGNetwork
objects which allows you to:
Make predictions with datastore input directly.
Save the network in a MAT file.
Use options provided by the predict
function for
DAGNetwork
objects.
For an example, see Assemble Multiple-Output Network for Prediction.
assembleNetwork
| functionToLayerGraph
| predict