SeparableConv1D
类keras.layers.SeparableConv1D(
filters,
kernel_size,
strides=1,
padding="valid",
data_format=None,
dilation_rate=1,
depth_multiplier=1,
activation=None,
use_bias=True,
depthwise_initializer="glorot_uniform",
pointwise_initializer="glorot_uniform",
bias_initializer="zeros",
depthwise_regularizer=None,
pointwise_regularizer=None,
bias_regularizer=None,
activity_regularizer=None,
depthwise_constraint=None,
pointwise_constraint=None,
bias_constraint=None,
**kwargs
)
1D 可分离卷积层。
这一层先执行逐通道卷积(depthwise convolution),该卷积独立作用于每个通道,然后执行逐点卷积(pointwise convolution),该卷积混合各通道的信息。如果 use_bias
为 True 并且提供了偏置项初始化器,它会在输出中添加一个偏置向量。之后,它会选择性地应用激活函数来生成最终输出。
参数
strides > 1
与 dilation_rate > 1
不兼容。"valid"
或 "same"
(不区分大小写)。"valid"
表示不进行填充。"same"
表示在输入的左/右或上/下均匀填充。当 padding="same"
且 strides=1
时,输出的大小与输入相同。"channels_last"
或 "channels_first"
。输入的维度顺序。"channels_last"
对应于形状为 (batch, steps, features)
的输入,而 "channels_first"
对应于形状为 (batch, features, steps)
的输入。它默认为 Keras 配置文件 ~/.keras/keras.json
中的 image_data_format
值。如果从未设置过,则默认为 "channels_last"
。input_channel * depth_multiplier
。None
,则不应用激活。True
,则会在输出中添加偏置项。"glorot_uniform"
)。"glorot_uniform"
)。Optimizer
更新后使用(例如,用于层权重的范数约束或值约束)。该函数必须接收未投影的变量作为输入,并返回投影后的变量(形状必须相同)。Optimizer
更新后使用。Optimizer
更新后使用。输入形状
data_format="channels_last"
: 形状为 (batch_shape, steps, channels)
的 3D 张量。data_format="channels_first"
: 形状为 (batch_shape, channels, steps)
的 3D 张量。输出形状
data_format="channels_last"
: 形状为 (batch_shape, new_steps, filters)
的 3D 张量。data_format="channels_first"
: 形状为 (batch_shape, filters, new_steps)
的 3D 张量。返回值
一个表示 activation(separable_conv1d(inputs, kernel) + bias)
的 3D 张量。
示例
>>> x = np.random.rand(4, 10, 12)
>>> y = keras.layers.SeparableConv1D(3, 4, 3, 2, activation='relu')(x)
>>> print(y.shape)
(4, 4, 4)