parameters: (inputs, num_outputs, kernel_size, stride, rate=1, scope=None)
docstring: Strided 2-D convolution with 'SAME' padding.
  
    When stride > 1, then we do explicit zero-padding, followed by conv2d with
    'VALID' padding.
  
    Note that
  
       net = conv2d_same(inputs, num_outputs, 3, stride=stride)
  
    is equivalent to
  
       net = tf.contrib.layers.conv2d(inputs, num_outputs, 3, stride=1,
       padding='SAME')
       net = subsample(net, factor=stride)
  
    whereas
  
       net = tf.contrib.layers.conv2d(inputs, num_outputs, 3, stride=stride,
       padding='SAME')
  
    is different when the input's height or width is even, which is why we add the
    current function. For more details, see ResnetUtilsTest.testConv2DSameEven().
  
    Args:
      inputs: A 4-D tensor of size [batch, height_in, width_in, channels].
      num_outputs: An integer, the number of output filters.
      kernel_size: An int with the kernel_size of the filters.
      stride: An integer, the output stride.
      rate: An integer, rate for atrous convolution.
      scope: Scope.
  
    Returns:
      output: A 4-D tensor of size [batch, height_out, width_out, channels] with
        the convolution output.
docstring_summary: Strided 2-D convolution with 'SAME' padding.
docstring_tokens: Strided 2 - D convolution with SAME padding .
function: def conv2d_same(inputs, num_outputs, kernel_size, stride, rate=1, scope=None):
    """Strided 2-D convolution with 'SAME' padding.
  
    When stride > 1, then we do explicit zero-padding, followed by conv2d with
    'VALID' padding.
  
    Note that
  
       net = conv2d_same(inputs, num_outputs, 3, stride=stride)
  
    is equivalent to
  
       net = tf.contrib.layers.conv2d(inputs, num_outputs, 3, stride=1,
       padding='SAME')
       net = subsample(net, factor=stride)
  
    whereas
  
       net = tf.contrib.layers.conv2d(inputs, num_outputs, 3, stride=stride,
       padding='SAME')
  
    is different when the input's height or width is even, which is why we add the
    current function. For more details, see ResnetUtilsTest.testConv2DSameEven().
  
    Args:
      inputs: A 4-D tensor of size [batch, height_in, width_in, channels].
      num_outputs: An integer, the number of output filters.
      kernel_size: An int with the kernel_size of the filters.
      stride: An integer, the output stride.
      rate: An integer, rate for atrous convolution.
      scope: Scope.
  
    Returns:
      output: A 4-D tensor of size [batch, height_out, width_out, channels] with
        the convolution output.
    """
    if stride == 1:
      return layers_lib.conv2d(
          inputs,
          num_outputs,
          kernel_size,
          stride=1,
          rate=rate,
          padding='SAME',
          scope=scope)
    else:
      kernel_size_effective = kernel_size + (kernel_size - 1) * (rate - 1)
      pad_total = kernel_size_effective - 1
      pad_beg = pad_total // 2
      pad_end = pad_total - pad_beg
      inputs = array_ops.pad(
          inputs, [[0, 0], [pad_beg, pad_end], [pad_beg, pad_end], [0, 0]])
      return layers_lib.conv2d(
          inputs,
          num_outputs,
          kernel_size,
          stride=stride,
          rate=rate,
          padding='VALID',
          scope=scope)
function_tokens: def conv2d_same ( inputs , num_outputs , kernel_size , stride , rate = 1 , scope = None ) : if stride == 1 : return layers_lib . conv2d ( inputs , num_outputs , kernel_size , stride = 1 , rate = rate , padding = 'SAME' , scope = scope ) else : kernel_size_effective = kernel_size + ( kernel_size - 1 ) * ( rate - 1 ) pad_total = kernel_size_effective - 1 pad_beg = pad_total // 2 pad_end = pad_total - pad_beg inputs = array_ops . pad ( inputs , [ [ 0 , 0 ] , [ pad_beg , pad_end ] , [ pad_beg , pad_end ] , [ 0 , 0 ] ] ) return layers_lib . conv2d ( inputs , num_outputs , kernel_size , stride = stride , rate = rate , padding = 'VALID' , scope = scope )