reflection_padding_2d
ReflectionPadding2D
¶
Bases: Layer
A layer for performing Reflection Padding on 2D arrays.
This class is intentionally not @traceable (models and layers are handled by a different process).
This layer assumes that you are using the a tensor shaped like (Batch, Height, Width, Channels). The implementation here is borrowed from https://stackoverflow.com/questions/50677544/reflection-padding-conv2d.
x = tf.reshape(tf.convert_to_tensor(list(range(9))), (1,3,3,1)) # ~ [[0, 1, 2], [3, 4, 5], [6, 7, 8]]
m = fe.layers.tensorflow.ReflectionPadding2D((1, 1))
y = m(x) # ~ [[4, 3, 4, 5, 4], [1, 0, 1, 2, 1], [4, 3, 4, 5, 4], [7, 6, 7, 8, 7], [4, 3, 4, 5, 4]]
m = fe.layers.tensorflow.ReflectionPadding2D((1, 0))
y = m(x) # ~ [[1, 0, 1, 2, 1], [4, 3, 4, 5, 4], [7, 6, 7, 8, 7]]
Parameters:
Name | Type | Description | Default |
---|---|---|---|
padding |
Tuple[int, int]
|
padding size (Width, Height). The padding size must be less than the size of the corresponding dimension in the input tensor. |
(1, 1)
|
Source code in fastestimator/fastestimator/layers/tensorflow/reflection_padding_2d.py
compute_output_shape
¶
If you are using "channels_last" configuration