The size calculation of the output vector of the inverse convolution operation in TensorFlow

Source: Internet
Author: User

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) 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.