DepthwiseConv2D
classtf_keras.layers.DepthwiseConv2D(
kernel_size,
strides=(1, 1),
padding="valid",
depth_multiplier=1,
data_format=None,
dilation_rate=(1, 1),
activation=None,
use_bias=True,
depthwise_initializer="glorot_uniform",
bias_initializer="zeros",
depthwise_regularizer=None,
bias_regularizer=None,
activity_regularizer=None,
depthwise_constraint=None,
bias_constraint=None,
**kwargs
)
Depthwise 2D convolution.
Depthwise convolution is a type of convolution in which each input channel is convolved with a different kernel (called a depthwise kernel). You can understand depthwise convolution as the first step in a depthwise separable convolution.
It is implemented via the following steps:
depth_multiplier
output channels.Unlike a regular 2D convolution, depthwise convolution does not mix information across different input channels.
The depth_multiplier
argument determines how many filter are applied to
one input channel. As such, it controls the amount of output channels that
are generated per input channel in the depthwise step.
Arguments
dilation_rate
value !=1.'valid'
or 'same'
(case-insensitive). "valid"
means
no padding. "same"
results in padding with zeros evenly to the
left/right or up/down of the input such that output has the same
height/width dimension as the input.filters_in * depth_multiplier
.channels_last
(default) or
channels_first
. The ordering of the dimensions in the inputs.
channels_last
corresponds to inputs with shape (batch_size, height,
width, channels)
while channels_first
corresponds to inputs with
shape (batch_size, channels, height, width)
. When unspecified, uses
image_data_format
value found in your TF-Keras config file at
~/.keras/keras.json
(if exists) else 'channels_last'.
Defaults to 'channels_last'.dilation_rate
value != 1 is incompatible with specifying any strides
value != 1.keras.activations
).keras.initializers
). If None, the default initializer
('glorot_uniform') will be used.keras.initializers
). If None, the default initializer ('zeros') will
be used.keras.regularizers
).keras.regularizers
).keras.regularizers
).keras.constraints
).keras.constraints
).Input shape
4D tensor with shape: [batch_size, channels, rows, cols]
if
data_format='channels_first'
or 4D tensor with shape: [batch_size, rows, cols, channels]
if
data_format='channels_last'.
Output shape
4D tensor with shape: [batch_size, channels * depth_multiplier, new_rows,
new_cols]
if data_format='channels_first'
or 4D tensor with shape: [batch_size,
new_rows, new_cols, channels * depth_multiplier]
if
data_format='channels_last'
. rows
and cols
values might have
changed due to padding.
Returns
A tensor of rank 4 representing
activation(depthwiseconv2d(inputs, kernel) + bias)
.
Raises
padding
is "causal".strides
> 1 and dilation_rate
> 1.