exportNetworkToSimulink - Generate Simulink model that contains deep learning layer blocks and subsystems that correspond to

  deep learning layer objects - MATLAB ([original](https://in.mathworks.com/help/deeplearning/ref/dlnetwork.exportnetworktosimulink.html)) ([raw](?raw))

Generate Simulink model that contains deep learning layer blocks and subsystems that correspond to deep learning layer objects

Since R2024b

Syntax

Description

[mdlInfo](#mw%5Fc55872a5-322b-4e8e-be20-e59812c07497) = exportNetworkToSimulink([net](#mw%5F1b39a89e-4f15-44de-ad8b-5055dea6cbe1)) creates a Simulink® model for a trained dlnetwork object, net. The model uses a fixed-step solver and contains deep learning layer blocks and subsystems that correspond to layers in the network. The function returns a structure that contains information about the generated model.

For a list of deep learning layer blocks and subsystems, see List of Deep Learning Layer Blocks and Subsystems. If the network contains a layer that does not have a corresponding deep learning layer block or subsystem, then the function generates a placeholder subsystem that contains an Assertion (Simulink) block. You can manually replace the Assertion block with an implementation of the layer.

Input Arguments

collapse all

Trained deep learning network to export as a Simulink model, specified as a dlnetwork object.

Data Types: dlnetwork

Name-Value Arguments

collapse all

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: exportNetworkToSimulink(myNetwork,ModelName="myExportedModel")

Name of the generated Simulink model, specified as a character vector or string.

Data Types: char | string

Folder path for saving the generated model, specified as a character vector or string. If you do not specify ModelPath, the function saves the model to the current working directory.

Data Types: char | string

Data type for generated inports, specified as a character vector or string. The value must correspond to a data type that is supported as the input type of anInport block, such as 'uint8','single', or 'Inherit: auto'. Other blocks in the generated model inherit the input type from the Inport blocks.

If you do not specify InputDataType, the generated inports use the value 'Inherit: auto'.

Data Types: char | string

Flag to expand layer blocks and subsystems to the top level of the generated model without wrapping the blocks in a subsystem, specified as a numeric or logical1 (true) or 0 (false).

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Flag to open the model after generating it, specified as a numeric or logical1 (true) or 0 (false).

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Sample time to use for the generated model, specified as a character vector or string. To use an inherited sample time, use a character vector or string of the form'_`Ts`_' or'[_`Ts`_ 0]', where_`Ts`_ is the sample time. For more information, see Specify Sample Time (Simulink).

Data Types: char | string

Flag to use stateful prediction, specified as one of these values:

If the input network contains a supported stateful layer, then the default value is true. Otherwise, the default value isfalse.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Flag to use frame-based processing for sequence networks, specified as a numeric or logical 1 (true) or 0 (false).

If you specify false, the generated model uses sample-based processing. The model assumes that the input data uses Simulink step time to represent the frame rate.

If you specify true, the generated model uses frame-based processing. The model sets the time (T) dimension of the inport to the value of the MinLength property of the sequenceInputLayer object in the sequence network.

For more information about sample- and frame-based processing, see Sample- and Frame-Based Concepts (DSP System Toolbox).

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Flag to save the input network in the workspace of the generated model, specified as a numeric or logical 1 (true) or0 (false).

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Flag to save the generated model in the folder path as an SLX (*.slx) file, specified as a numeric or logical 1 (true) or0 (false).

Specify where to save the model using the ModelPath name-value argument. By default, the exportNetworkToSimulink function saves the generated model in the current directory.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Output Arguments

collapse all

Information about the generated model, returned as a structure. This table describes the fields of the structure.

Field Description
ModelName Name of the generated model, returned as a character vector.
NetworkName Name of the network in the generated model workspace, returned as a character vector.
ModelPath Full file path of the generated model, returned as a character vector.
InputDataType Input data type of the generated model, returned as a character vector.
BlockParameters Parameters of blocks in the generated model, returned as a structure array. Each structure in the array contains a field for each parameter of a block.
BlockConnections Connections between blocks in the generated model, returned as a table. The table contains the variables Source andDestination. Each row in the table represents the source and destination blocks of a connection in the generated model.
NumInports The number of inports in the generated model, returned as a scalar.
NumOutports The number of outports in the generated model, returned as a scalar.
SampleTime The sample time of the generated model, returned as a character vector.
Stateful Type of prediction that the model uses, either stateless or stateful, returned as a boolean.
FrameBased Type of processing that the model uses, either frame-based or sample-based, returned as a boolean.

Limitations

Tips

Version History

Introduced in R2024b

expand all

Choose whether or not to save the generated model in the model path as an SLX (*.slx) file by setting the SaveModelToFile flag. Specify the model path using the ModelPath name-value argument. By default, the exportNetworkToSimulink function saves the generated model in the current directory.

See Also

dlnetwork

Topics