pub struct ConvolutionLayerParams {
pub output_channels: u64,
pub kernel_channels: u64,
pub n_groups: u64,
pub kernel_size: Vec<u64>,
pub stride: Vec<u64>,
pub dilation_factor: Vec<u64>,
pub is_deconvolution: bool,
pub has_bias: bool,
pub weights: Option<WeightParams>,
pub bias: Option<WeightParams>,
pub output_shape: Vec<u64>,
pub convolution_padding_type: Option<ConvolutionPaddingType>,
}Expand description
A layer that performs spatial convolution or deconvolution.
.. code::
y = ConvolutionLayer(x)Requires 1 or 2 inputs and produces 1 output.
Input First Input: A blob with rank greater than or equal to 4. Rank 4 blob represents [Batch, channels, height, width]. For ranks greater than 4, the leading dimensions, starting from 0 to -4 (inclusive), are all treated as batch.
From Core ML specification version 4 onwards (iOS >= 13, macOS >= 10.15).
convolution layer can have 2 inputs, in which case the second input is
the blob representing the weights. This is allowed when "isDeconvolution" = False.
The weight blob should have shape
``\[outputChannels, kernelChannels, kernelHeight, kernelWidth\]``,
where kernelChannels == inputChannels / nGroups.Output Rank is same as the input. e.g.: for rank 4 input, output shape is [B, C_out, H_out, W_out]
If dilationFactor is not 1, effective kernel size is
modified as follows:
.. code::
KernelSize\[0\] <-- (kernelSize\[0\]-1) * dilationFactor\[0\] + 1
KernelSize\[1\] <-- (kernelSize\[1\]-1) * dilationFactor\[1\] + 1Type of padding can be valid or same. Output spatial dimensions depend on the
the type of padding. For details, refer to the descriptions of the messages “ValidPadding”
and “SamePadding”. Padded values are all zeros.
For Deconvolution, ConvolutionPaddingType (valid or same) is ignored when outputShape is set.
Fields§
§output_channels: u64The number of kernels.
Same as C_out used in the layer description.
kernel_channels: u64Channel dimension of the kernels.
Must be equal to inputChannels / nGroups, if isDeconvolution == False
Must be equal to inputChannels, if isDeconvolution == True
n_groups: u64Group convolution, i.e. weight reuse along channel axis. Input and kernels are divided into g groups and convolution / deconvolution is applied within the groups independently. If not set or 0, it is set to the default value 1.
kernel_size: Vec<u64>Must be length 2 in the order \[H, W\].
If not set, default value \[3, 3\] is used.
stride: Vec<u64>Must be length 2 in the order \[H, W\].
If not set, default value \[1, 1\] is used.
dilation_factor: Vec<u64>Must be length 2 in order \[H, W\].
If not set, default value \[1, 1\] is used.
It is ignored if isDeconvolution == true.
is_deconvolution: boolFlag to specify whether it is a deconvolution layer.
has_bias: boolFlag to specify whether a bias is to be added or not.
weights: Option<WeightParams>Weights associated with this layer.
If convolution (isDeconvolution == false), weights have the shape
\[outputChannels, kernelChannels, kernelHeight, kernelWidth\], where kernelChannels == inputChannels / nGroups
If deconvolution (isDeconvolution == true) weights have the shape
\[kernelChannels, outputChannels / nGroups, kernelHeight, kernelWidth\], where kernelChannels == inputChannels
bias: Option<WeightParams>Must be of size [outputChannels].
output_shape: Vec<u64>The output shape, which has length 2 \[H_out, W_out\].
This is used only for deconvolution (isDeconvolution == true).
If not set, the deconvolution output shape is calculated
based on ConvolutionPaddingType.
convolution_padding_type: Option<ConvolutionPaddingType>The type of padding.
Trait Implementations§
Source§impl Clone for ConvolutionLayerParams
impl Clone for ConvolutionLayerParams
Source§fn clone(&self) -> ConvolutionLayerParams
fn clone(&self) -> ConvolutionLayerParams
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 ConvolutionLayerParams
impl Debug for ConvolutionLayerParams
Source§impl Default for ConvolutionLayerParams
impl Default for ConvolutionLayerParams
Source§impl Message for ConvolutionLayerParams
impl Message for ConvolutionLayerParams
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 ConvolutionLayerParams
impl PartialEq for ConvolutionLayerParams
Source§fn eq(&self, other: &ConvolutionLayerParams) -> bool
fn eq(&self, other: &ConvolutionLayerParams) -> bool
self and other values to be equal, and is used by ==.