ResizeLayer

ResizeLayer[{n}]

resizes a matrix of size c0×n0 to be size c0×n.

ResizeLayer[{h,w}]

resizes a tensor of dimensions c0×h0×w0 to be size c0×h×w.

Details and Options

  • ResizeLayer treats the first dimension as a channel dimension, which remains unchanged.
  • ResizeLayer performs linear interpolation if there is one remaining dimension and bilinear interpolation if there are two remaining dimensions.
  • In ResizeLayer[{d1,,dn}], any of the di can be one of the following:
  • nscale dimension to be size n
    Scaled[r]scale dimension to be a ratio r of the original size
    Allleave the dimension unchanged
  • ResizeLayer[][input] explicitly computes the output from applying the layer.
  • ResizeLayer[][{input1,input2,}] explicitly computes outputs for each of the inputi.
  • ResizeLayer is typically used inside NetChain, NetGraph, etc.
  • ResizeLayer exposes the following ports for use in NetGraph etc.:
  • "Input"a tensor
    "Output"a tensor of the same rank as the input
  • The following optional parameters can be included:
  • ResamplingAutomaticresampling method
  • Possible explicit settings for the Resampling method include:
  • "Linear"piecewise linear interpolation
    "Nearest"nearest neighbor
  • When the Resampling method is "Nearest", only the special case of ResizeLayer[{Scaled[n]}] and ResizeLayer[{Scaled[n], Scaled[n]}], where n is a positive integer, is currently implemented.
  • When it cannot be inferred from other layers in a larger net, the option "Input"{d1,,dn} can be used to fix the input of ResizeLayer to be a tensor of dimensions d1××dn.

Examples

open allclose all

Basic Examples  (2)

Create a ResizeLayer that resizes a 3-tensor to be of size c×8×8.

In[1]:=
Click for copyable input
Out[1]=

Create a ResizeLayer that resizes a matrix to be of size c×2.

In[1]:=
Click for copyable input
Out[1]=

Apply the layer to an input matrix (where c is 1):

In[2]:=
Click for copyable input
Out[2]=

Scope  (2)

See Also

ImageResize  SpatialTransformationLayer  ReshapeLayer  FlattenLayer  NetChain  NetGraph

Introduced in 2017
(11.1)
| Updated in 2017
(11.2)