pub struct PaddingLayerParams {
pub padding_amounts: Option<BorderAmounts>,
pub padding_type: Option<PaddingType>,
}Expand description
A layer that performs padding along spatial dimensions.
.. code::
y = PaddingLayer(x)Requires 1 input and produces 1 output.
Input
A blob with rank at least 2.
e.g.: blob with shape \[H_in, W_in\].
For ranks greater than 2, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch
i.e. Padding is applied on last two dimensions.
Output
Same rank as the input.
e.g.: blob with shape \[H_out, W_out\].
Output dimensions are calculated as follows:
.. code::
H_out = H_in + topPaddingAmount + bottomPaddingAmount
W_out = W_in + leftPaddingAmount + rightPaddingAmount
topPaddingAmount == Height startEdgeSize == borderAmounts\[0\].startEdgeSize
bottomPaddingAmount == Height endEdgeSize == borderAmounts\[0\].endEdgeSize
leftPaddingAmount == Width startEdgeSize == borderAmounts\[1\].startEdgeSize
rightPaddingAmount == Width endEdgeSize == borderAmounts\[1\].endEdgeSizeThere are three types of padding:
PaddingConstant, which fills a constant value at the border.PaddingReflection, which reflects the values at the border.PaddingReplication, which replicates the values at the border.
Given the following input:
.. code::
\[1, 3, 4\] : 1 2 3 4
5 6 7 8
9 10 11 12Here is the output of applying the padding
(top=2, left=2, bottom=0, right=0)
with each of the supported types:
-
PaddingConstant(value = 0): .. code::\[1, 5, 6\] : 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 2 3 4 0 0 5 6 7 8 0 0 9 10 11 12 -
PaddingReflection: .. code::\[1, 5, 6\] : 11 10 9 10 11 12 7 6 5 6 7 8 3 2 1 2 3 4 7 6 5 6 7 8 11 10 9 10 11 12 -
PaddingReplication: .. code::\[1, 5, 6\] : 1 1 1 2 3 4 1 1 1 2 3 4 1 1 1 2 3 4 5 5 5 6 7 8 9 9 9 10 11 12
Fields§
§padding_amounts: Option<BorderAmounts>Amounts to be padded to the input.
padding_type: Option<PaddingType>Trait Implementations§
Source§impl Clone for PaddingLayerParams
impl Clone for PaddingLayerParams
Source§fn clone(&self) -> PaddingLayerParams
fn clone(&self) -> PaddingLayerParams
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PaddingLayerParams
impl Debug for PaddingLayerParams
Source§impl Default for PaddingLayerParams
impl Default for PaddingLayerParams
Source§impl Message for PaddingLayerParams
impl Message for PaddingLayerParams
Source§fn encoded_len(&self) -> usize
fn encoded_len(&self) -> usize
Source§fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
fn encode_length_delimited(
&self,
buf: &mut impl BufMut,
) -> Result<(), EncodeError>where
Self: Sized,
Source§fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
fn encode_length_delimited_to_vec(&self) -> Vec<u8> ⓘwhere
Self: Sized,
Source§fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>where
Self: Default,
Source§fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self. Read moreSource§fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>where
Self: Sized,
self.Source§impl PartialEq for PaddingLayerParams
impl PartialEq for PaddingLayerParams
Source§fn eq(&self, other: &PaddingLayerParams) -> bool
fn eq(&self, other: &PaddingLayerParams) -> bool
self and other values to be equal, and is used by ==.