PaddingLayer

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

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

Details and Options

  • PaddingLayer is typically used inside NetChain, NetGraph, etc.
  • The following optional parameter can be included:
  • Padding0type of padding to use
  • Possible explicit settings for the Padding option include:
  • valpad with a constant value val
    "Fixed"repetitions of the elements on each boundary
    "Reflected"reflections of the array in the boundary
  • The default option is to pad with the value 0.
  • 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 array.
  • PaddingLayer exposes the following ports for use in NetGraph etc.:
  • "Input"an array of rank 1 or higher
    "Output"an array of rank 1 or higher
  • 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 an array of dimensions d1××dn.
  • PaddingLayer[][input] explicitly computes the output from applying the layer.
  • PaddingLayer[][{input1,input2,}] explicitly computes outputs for each of the inputi.
  • When given a NumericArray as input, the output will be a NumericArray.
  • Options[PaddingLayer] gives the list of default options to construct the layer. Options[PaddingLayer[]] gives the list of default options to evaluate the layer on some data.
  • Information[PaddingLayer[]] gives a report about the layer.
  • Information[PaddingLayer[],prop] gives the value of the property prop of PaddingLayer[]. Possible properties are the same as for NetGraph.

Examples

open allclose all

Basic Examples  (2)

Create a PaddingLayer that pads a vector with zeros:

Create a PaddingLayer that pads a vector with zeros:

Apply the layer to a vector:

Scope  (3)

Create a PaddingLayer that pads a vector with zeros:

The layer threads across a batch of examples:

Create a PaddingLayer that pads a matrix:

Apply the layer to a matrix:

Create a PaddingLayer that pads an image encoded as a 3-dimensional array, using "Fixed" padding:

Options  (3)

Padding  (3)

Use -999 as the padding value:

Apply the layer to a vector:

Use the "Fixed" padding method:

Apply the layer to a vector:

Use the "Reflected" padding method:

Apply the layer to a vector:

Properties & Relations  (1)

PaddingLayer is equivalent to ArrayPad:

PaddingLayer also supports the "Fixed" padding type:

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