Inverse convolution operation in TensorFlow
Inverse convolution in TensorFlow
outputs = Nn.conv2d_transpose (
inputs,
Self.kernel,
output_shape_tensor,
strides,
padding= Self.padding.upper (),
Data_format=utils.convert_data_format (Self.data_format, ndim=4))
Here the Output_shape_tensor, width and height are calculated as follows, and can be designed filter_size and padding according to the desired output.
Size calculation of output tensor
def deconv_output_length (input_length, filter_size, padding, stride): ""
"determines output length of a transposed Convolution given input length.
Arguments:
Input_length:integer.
Filter_size:integer.
Padding:one of "Same", "valid", "full".
Stride:integer.
Returns: The
output Length (integer).
"" If Input_length is none: Return
none
input_length *= Stride
If padding = ' valid ':
input_length + = ma X (filter_size-stride, 0)
elif padding = = ' full ':
input_length-= (stride + filter_size-2) return
Input_ Length
There is no need to specify Output_shape in the Slim.conv2d_transpose, we can set the kernel size according to the requirement
conv2d_transpose (inputs, filters, Kernel_size, strides= (1, 1), padding= ' Vali d ', data_format= ' channels_last ', Activation=none, Use_bias=true, Kernel_initializer=none, bias_initial Izer=tf.zeros_initializer (), Kernel_regularizer=none, Bias_regularizer=none, Activity_regularizer=none, ke Rnel_constraint=none, Bias_constraint=none, Trainable=true, Name=none, Reuse=none)