• tesnorflow Conv2DTranspose


    tensorflow/python/layers/convolutional.py   
      # Infer the dynamic output shape:
        out_height = utils.deconv_output_length(height,
                                                kernel_h,
                                                self.padding,
                                                stride_h)
        out_width = utils.deconv_output_length(width,
                                               kernel_w,
                                               self.padding,
                                               stride_w)
        if self.data_format == 'channels_first':
          output_shape = (batch_size, self.filters, out_height, out_width)
          strides = (1, 1, stride_h, stride_w)
        else:
          output_shape = (batch_size, out_height, out_width, self.filters)
          strides = (1, stride_h, stride_w, 1)
    
        output_shape_tensor = array_ops.stack(output_shape)
        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))
    
    /tensorflow/python/layers/utils.py
    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 += max(filter_size - stride, 0)
      elif padding == 'full':
        input_length -= (stride + filter_size - 2)
      return input_length
    

      

    注意 deconv中的kernel 是需要rotate 180度 才直接相乘的,而conv中不用旋转直接相乘。

  • 相关阅读:
    dev c++ 中显示计算机中丢失libiconv2.dll
    poj 1456 Supermarket
    codeforce 867E Buy Low Sell High
    Java编写程序时出现警告:Resource leak: input is never closed 解决方法
    codeforce 8A
    CF1110B
    ZOJ 1914 Arctic Network
    POJ 1258 Agri-Net
    Poj 1751 Highways
    ZOJ 2158 Truck History
  • 原文地址:https://www.cnblogs.com/mlj318/p/7131075.html
Copyright © 2020-2023  润新知