resize2dLayer

2-D resize layer

Description

A 2-D resize layer resizes 2-D input by a scale factor or to a specified height and width. Use of this layer requires Deep Learning Toolbox™.

Creation

Description

example

layer = resize2dLayer('Scale',scale) creates a 2-D resize layer and sets the Scale property as the scale factor specified by scale.

example

layer = resize2dLayer('OutputSize',outputSize) creates a 2-D resize layer and sets the OutputSize property with the height and width specified by outputSize.

example

layer = resize2dLayer(___,Name,Value) sets the optional Method, GeometricTransformMode, NearestRoundingMode, and Name properties using name-value pair arguments. You can specify multiple name-value pair arguments. Enclose each property name in single quotes.

Properties

expand all

Resize

Scale factor to resize input, specified as 2-element row vector of positive numbers. The scale factors are for the row and column dimensions, respectively. When creating the layer, you can specify Scale as a scalar to use the same value for both dimensions.

Output size of resized input, specified as a 2-element row vector of positive integers of the form [nrows ncols]. You can specify one element as NaN, in which case the layer computes the value automatically to preserve the aspect ratio of the input.

Interpolation method, specified as 'nearest' for nearest neighbor interpolation or 'bilinear' for bilinear interpolation.

Geometric transformation mode to map points from input space to output space, specified as'half-pixel' or 'asymmetric'.

Rounding mode for nearest neighbor interpolation, specified as 'round' or 'onnx-10'. The value 'round' uses the same rounding behavior as the MATLAB® round function. The value 'onnx-10' reproduces the resizing behavior of the ONNX™ (Open Neural Network Exchange) opset 10 resize operator.

This property is valid when the Method property is 'nearest'.

Layer

Layer name, specified as a character vector or a string scalar. To include a layer in a layer graph, you must specify a nonempty unique layer name. If you train a series network with the layer and Name is set to '', then the software automatically assigns a name to the layer at training time.

Data Types: char | string

Number of inputs of the layer. This layer accepts a single input only.

Data Types: double

Input names of the layer. This layer accepts a single input only.

Data Types: cell

Number of outputs of the layer. This layer has a single output only.

Data Types: double

Output names of the layer. This layer has a single output only.

Data Types: cell

Examples

collapse all

Create a 2-D resize layer with a horizontal scale factor of 2 and a vertical scale factor of 4.

layer = resize2dLayer('Scale',[2 4])
layer = 
  Resize2DLayer with properties:

                      Name: ''
                     Scale: [2 4]
                OutputSize: []
                    Method: 'nearest'
    GeometricTransformMode: 'half-pixel'
       NearestRoundingMode: 'round'

  Show all properties

Create a 2-D resize layer named 'resize224' with an output size of [224 224].

layer = resize2dLayer('OutputSize',[224 224],'Name','resize224')
layer = 
  Resize2DLayer with properties:

                      Name: 'resize224'
                     Scale: []
                OutputSize: [224 224]
                    Method: 'nearest'
    GeometricTransformMode: 'half-pixel'
       NearestRoundingMode: 'round'

  Show all properties

Create a 2-D resize layer named 'rescale0.5' with a uniform scale factor of 0.5. Specify the interpolation method as bilinear interpolation.

layer = resize2dLayer('Scale',0.5,'Method','bilinear','Name','rescale0.5')
layer = 
  Resize2DLayer with properties:

                      Name: 'rescale0.5'
                     Scale: [0.5000 0.5000]
                OutputSize: []
                    Method: 'bilinear'
    GeometricTransformMode: 'half-pixel'
       NearestRoundingMode: 'round'

  Show all properties

References

[1] Open Neural Network Exchange. https://github.com/onnx/.

[2] ONNX. https://onnx.ai/.

See Also

| | (Deep Learning Toolbox) | (Deep Learning Toolbox) | (Deep Learning Toolbox)

Topics

Introduced in R2020b