ZeroPadding1D
类keras.layers.ZeroPadding1D(padding=1, data_format=None, **kwargs)
用于一维输入(例如时间序列)的零填充层。
示例
>>> input_shape = (2, 2, 3)
>>> x = np.arange(np.prod(input_shape)).reshape(input_shape)
>>> x
[[[ 0 1 2]
[ 3 4 5]]
[[ 6 7 8]
[ 9 10 11]]]
>>> y = keras.layers.ZeroPadding1D(padding=2)(x)
>>> y
[[[ 0 0 0]
[ 0 0 0]
[ 0 1 2]
[ 3 4 5]
[ 0 0 0]
[ 0 0 0]]
[[ 0 0 0]
[ 0 0 0]
[ 6 7 8]
[ 9 10 11]
[ 0 0 0]
[ 0 0 0]]]
参数
(left_pad, right_pad)
)。"channels_last"
(默认)或 "channels_first"
。输入中维度的顺序。"channels_last"
对应于形状为 (batch_size, axis_to_pad, channels)
的输入,而 "channels_first"
对应于形状为 (batch_size, channels, axis_to_pad)
的输入。如果未指定,则使用 Keras 配置文件 ~/.keras/keras.json
(如果存在)中找到的 image_data_format
值。默认为 "channels_last"
。输入形状
3D 张量,形状如下:- 如果 data_format
为 "channels_last"
:(batch_size, axis_to_pad, features)
- 如果 data_format
为 "channels_first"
:(batch_size, features, axis_to_pad)
输出形状
3D 张量,形状如下:- 如果 data_format
为 "channels_last"
:(batch_size, padded_axis, features)
- 如果 data_format
为 "channels_first"
:(batch_size, features, padded_axis)