PaddingLayer

PaddingLayer[{{m1,n1},{m2,n2},}]

represents a net layer that pads an input tensor with mi elements at the beginning and ni elements at the end at level i of the tensor.

Details and Options

  • The following optional parameters can be included:
  • "Padding"Automatictype of padding to use
  • PaddingLayer[][input] explicitly computes the output from applying the layer.
  • PaddingLayer[][{input1,input2,}] explicitly computes outputs for each of the inputi.
  • PaddingLayer is typically used inside NetChain, NetGraph, etc.
  • PaddingLayer exposes the following ports for use in NetGraph etc.:
  • "Input"a tensor of rank 1, 2, 3 or 4
    "Output"a tensor of rank 1, 2, 3 or 4
  • Possible explicit settings for the "Padding" option include:
  • valpad with a constant value val
    "Fixed"repetitions of the elements on each boundary
  • The "Padding" value "Fixed" indicates that the rectangles of pixels added at each corner should be copies of the pixels at the corners of the original tensor.
  • 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 PaddingLayer to be a tensor of dimensions d1××dn.

Examples

open allclose all

Basic Examples  (2)

Create a PaddingLayer that pads a vector with zeros:

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

Create a PaddingLayer that pads a vector with zeros:

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

Apply the layer to a vector:

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

Scope  (3)

Options  (2)

Properties & Relations  (1)

See Also

ReshapeLayer  NetChain  NetGraph  NetTrain

Introduced in 2017
(11.1)