DepthwiseConv2D
类tf_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
)
深度可分离二维卷积。
深度可分离卷积是一种卷积类型,其中每个输入通道都与一个不同的核(称为深度卷积核)进行卷积。您可以将深度可分离卷积理解为深度可分离卷积的第一步。
其实现步骤如下:
depth_multiplier
个输出通道的单个深度卷积核对每个通道进行卷积。与常规的二维卷积不同,深度可分离卷积不会混合不同输入通道的信息。
depth_multiplier
参数决定了应用于一个输入通道的滤波器数量。因此,它控制了深度步骤中每个输入通道生成的输出通道数量。
参数
dilation_rate
值 != 1 不兼容。'valid'
或 'same'
之一(不区分大小写)。"valid"
表示不填充。"same"
会导致在输入的左侧/右侧或上下方用零均匀填充,以便输出具有与输入相同的高度/宽度维度。filters_in * depth_multiplier
。channels_last
(默认)或 channels_first
之一。输入中维度的顺序。channels_last
对应于形状为 (batch_size, height, width, channels)
的输入,而 channels_first
对应于形状为 (batch_size, channels, height, width)
的输入。如果未指定,则使用 TF-Keras 配置文件 ~/.keras/keras.json
(如果存在)中找到的 image_data_format
值,否则为 'channels_last'。默认为 'channels_last'。dilation_rate
值 != 1 与指定任何 strides
值 != 1 不兼容。keras.activations
)。keras.initializers
)。如果为 None,则将使用默认初始化器('glorot_uniform')。keras.initializers
)。如果为 None,则将使用默认初始化器('zeros')。keras.regularizers
)。keras.regularizers
)。keras.regularizers
)。keras.constraints
)。keras.constraints
)。输入形状
如果 data_format='channels_first',则为形状为 [batch_size, channels, rows, cols]
的 4D 张量;如果 data_format='channels_last',则为形状为 [batch_size, rows, cols, channels]
的 4D 张量。
输出形状
如果 data_format='channels_first'
,则为形状为 [batch_size, channels * depth_multiplier, new_rows, new_cols]
的 4D 张量;如果 data_format='channels_last'
,则为形状为 [batch_size, new_rows, new_cols, channels * depth_multiplier]
的 4D 张量。由于填充,rows
和 cols
值可能已更改。
返回值
一个表示 activation(depthwiseconv2d(inputs, kernel) + bias)
的秩为 4 的张量。
引发异常
padding
为 "causal"。strides
> 1 和 dilation_rate
> 1 时。