Conv2DTranspose 类keras.layers.Conv2DTranspose(
filters,
kernel_size,
strides=(1, 1),
padding="valid",
output_padding=None,
data_format=None,
dilation_rate=(1, 1),
activation=None,
use_bias=True,
kernel_initializer="glorot_uniform",
bias_initializer="zeros",
kernel_regularizer=None,
bias_regularizer=None,
activity_regularizer=None,
kernel_constraint=None,
bias_constraint=None,
**kwargs
)
2D 转置卷积层。
通常需要转置卷积,是因为需要使用与正常卷积方向相反的变换,即从具有某个卷积输出形状的事物变换为具有其输入形状的事物,同时保持与该卷积兼容的连接模式。
参数
strides > 1 与 dilation_rate > 1 不兼容。"valid" 或 "same"(不区分大小写)。"valid" 表示无填充。"same" 会在输入的左/右或上/下均匀填充。当 padding="same" 且 strides=1 时,输出与输入具有相同的大小。None(默认),则推断输出形状。"channels_last" 或 "channels_first"。输入中维度的顺序。"channels_last" 对应于形状为 (batch_size, height, width, channels) 的输入,而 "channels_first" 对应于形状为 (batch_size, channels, height, width) 的输入。它默认为 Keras 配置文件 ~/.keras/keras.json 中找到的 image_data_format 值。如果您从未设置过,则默认为 "channels_last"。dilation_rate:一个整数或 2 个整数的元组/列表,指定所有空间维度上扩张卷积的扩张率。不支持为不同维度指定不同的扩张率。目前,指定任何 dilation_rate 值 != 1 与指定任何步长值 != 1 不兼容。None,则不应用激活。True,则会将偏置添加到输出中。None,将使用默认初始化器("glorot_uniform")。None,将使用默认初始化器("zeros")。Optimizer 更新核后应用于核(例如,用于实现层权重的范数约束或值约束)。该函数必须将未投影的变量作为输入,并且必须返回投影的变量(其形状必须相同)。在异步分布式训练时使用约束是不安全的。Optimizer 更新偏置后应用于偏置。输入形状
data_format="channels_last":形状为 (batch_size, height, width, channels) 的 4D 张量data_format="channels_first":形状为 (batch_size, channels, height, width) 的 4D 张量输出形状
data_format="channels_last":形状为 (batch_size, new_height, new_width, filters) 的 4D 张量data_format="channels_first":形状为 (batch_size, filters, new_height, new_width) 的 4D 张量返回
一个 4D 张量,表示 activation(conv2d_transpose(inputs, kernel) + bias)。
引发
strides > 1 和 dilation_rate > 1 都存在时。参考文献
示例
>>> x = np.random.rand(4, 10, 8, 128)
>>> y = keras.layers.Conv2DTranspose(32, 2, 2, activation='relu')(x)
>>> print(y.shape)
(4, 20, 16, 32)