Conv2DTranspose
classtf_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
)
Transposed convolution layer (sometimes called Deconvolution).
The need for transposed convolutions generally arises from the desire to use a transformation going in the opposite direction of a normal convolution, i.e., from something that has the shape of the output of some convolution to something that has the shape of its input while maintaining a connectivity pattern that is compatible with said convolution.
When using this layer as the first layer in a model,
provide the keyword argument input_shape
(tuple of integers or None
, does not include the sample axis),
e.g. input_shape=(128, 128, 3)
for 128x128 RGB pictures
in data_format="channels_last"
.
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.None
(default), the output shape is inferred.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 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 stride value != 1.keras.activations
).kernel
weights matrix
(see keras.initializers
). Defaults to 'glorot_uniform'.keras.initializers
). Defaults to 'zeros'.kernel
weights matrix (see 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, filters, new_rows, new_cols)
if
data_format='channels_first'
or 4D tensor with shape:
(batch_size, new_rows, new_cols, filters)
if
data_format='channels_last'. rows
and cols
values might have changed
due to padding.
If output_padding
is specified:
new_rows = ((rows - 1) * strides[0] + kernel_size[0] - 2 * padding[0] +
output_padding[0])
new_cols = ((cols - 1) * strides[1] + kernel_size[1] - 2 * padding[1] +
output_padding[1])
Returns
A tensor of rank 4 representing
activation(conv2dtranspose(inputs, kernel) + bias)
.
Raises
padding
is "causal".strides
> 1 and dilation_rate
> 1.References