Reshape Layer
R2026bReshape Layer block
To add a block to a model, double-click the canvas and start typing the block name. Then, select the block from the list.
Libraries:
Deep Learning Toolbox /
Deep Learning Layers /
Utility Layers
Description
The Reshape Layer block reshapes layer input data to the specified output size.
The exportNetworkToSimulink function generates this block to represent a reshapeLayer
object.
Examples
Export a trained neural network to Simulink® as layer blocks.
For most workflows, you do not need to create neural networks in Simulink. Instead, import or train a neural network in MATLAB® and export it to Simulink.
Suppose that you have a trained neural network net specified as
a dlnetwork object. Export the network to Simulink using the exportNetworkToSimulink function.
mdlInfo = exportNetworkToSimulink(net)

The exported Simulink model represents the neural network as a subsystem. To view the layer blocks, open the subsystem. This example shows the first few blocks of a neural network.

To view and edit the layer block parameters, open the corresponding layer block mask. This example shows the parameters for the ReLU block.

Using the layer block parameters, you can configure aspects like data types and execution options like sample times.
Ports
Input
Input data to reshape.
Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point
Complex Number Support: Yes
Output
Reshaped output data.
Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | fixed point
Complex Number Support: Yes
Parameters
To edit block parameters interactively, use the Property Inspector. From the Simulink Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.
Main
Size of the reshaped output, specified as an array of positive scalars.
Each element indicates the output size of the corresponding dimension given by the
Operation dimension parameter. For example, if
Operation dimension is
spatial-channel, then the elements of Output
size indicate the sizes of the spatial and channel dimensions of the
layer output.
Programmatic Use
Block Parameter:
OutputSize |
| Type: character vector |
Values:
'[1,1]' | '<array>' |
Default:
'[1,1]' |
Dimension along which to reshape the data, specified as one of these values:
all— Reshape data by reordering the elements in all dimensions.spatial-channel— Reshape data by reordering the elements in the spatial and channel dimensions only. Use this option when you have image or image-sequence data with varying batch sizes or sequence lengths.A vector of positive integers — Reshape data along the specified dimensions. The vector must specify a contiguous range of dimensions in the form
[m:n]. For example,[2,3]reshapes the data along the second and third dimensions.
Dependencies
Setting this parameter to spatial-channel enables the
Data format parameter.
Setting this parameter to a vector of positive integers enables the Input size parameter.
Programmatic Use
Block Parameter:
OperationDimension |
| Type: character vector |
Values:
'all' | 'spatial-channel' |
'[m:n]' |
Default:
'all' |
Data format for the input data. The options use the same notation as the fmt
argument of the dlarray object, except that these data formats do not
include the batch (B) or unspecified (U) dimension.
The data itself can include additional batch or unspecified dimension of size
1. To reshape data with a batch size greater than one, set
Operation dimension to all or to a
vector of positive integers.
Dependencies
To enable this parameter, set Operation dimension to
spatial-channel.
Programmatic Use
Block Parameter:
DataFormat |
| Type: character vector |
Values:
'SSC' | 'C' | 'CT' |
'SC' | 'SSSC' |
Default:
'SSC' |
Size of the input data to the block, specified as an array of positive scalars. To
determine the activations of the layer that precedes a reshapeLayer object, you can use the analyzeNetwork function.
Dependencies
To enable this parameter, set Operation dimension to a vector of positive integers.
Programmatic Use
Block Parameter:
InputSize |
| Type: character vector |
Values:
'1' | '<array>' |
Default:
'1' |
Execution
Specify the discrete interval between sample time hits or specify another type of sample time, such as continuous (0) or inherited (-1). For more options, see Types of Sample Time (Simulink).
By default, the block inherits its sample time based on the context of the block within the model.
Programmatic Use
To set the block parameter value
programmatically, use the set_param (Simulink) function.
Parameter:
SampleTime |
Data Types:
char |
Values:
'-1' | scalar |
Default:
'-1' |
Version History
Introduced in R2026b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)