lib/nets/mobilenet_v1.py
def separable_conv2d_same(inputs, kernel_size, stride, rate=1, scope=None):
  """Strided 2-D separable convolution with 'SAME' padding.
  Args:
    inputs: A 4-D tensor of size [batch, height_in, width_in, channels].
    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.
  """

  # By passing filters=None
  # separable_conv2d produces only a depth-wise convolution layer
  if stride == 1:
    return slim.separable_conv2d(inputs, None, kernel_size, 
                                  depth_multiplier=1, 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 = tf.pad(inputs,
                    [[0, 0], [pad_beg, pad_end], [pad_beg, pad_end], [0, 0]])
    return slim.separable_conv2d(inputs, None, kernel_size, 
                                  depth_multiplier=1, stride=stride, rate=rate, 
                                  padding='VALID', scope=scope)
Strided 2-D separable convolution with 'SAME' padding.
  Args:
    inputs: A 4-D tensor of size [batch, height_in, width_in, channels].
    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.
  
Strided 2-D separable convolution with 'SAME' padding.
Strided 2 - D separable convolution with ' SAME ' padding .
def separable_conv2d_same(inputs, kernel_size, stride, rate=1, scope=None):
  if stride == 1:
    return slim.separable_conv2d(inputs, None, kernel_size, 
                                  depth_multiplier=1, 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 = tf.pad(inputs,
                    [[0, 0], [pad_beg, pad_end], [pad_beg, pad_end], [0, 0]])
    return slim.separable_conv2d(inputs, None, kernel_size, 
                                  depth_multiplier=1, stride=stride, rate=rate, 
                                  padding='VALID', scope=scope)
def separable_conv2d_same ( inputs , kernel_size , stride , rate = 1 , scope = None ) : if stride == 1 : return slim . separable_conv2d ( inputs , None , kernel_size , depth_multiplier = 1 , 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 = tf . pad ( inputs , [ [ 0 , 0 ] , [ pad_beg , pad_end ] , [ pad_beg , pad_end ] , [ 0 , 0 ] ] ) return slim . separable_conv2d ( inputs , None , kernel_size , depth_multiplier = 1 , stride = stride , rate = rate , padding = 'VALID' , scope = scope )
Strided 2-D separable convolution with 'SAME' padding.
Strided 2 - D separable convolution with ' SAME ' padding .
"""Strided 2-D separable convolution with 'SAME' padding.
  Args:
    inputs: A 4-D tensor of size [batch, height_in, width_in, channels].
    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.
  """ # By passing filters=None # separable_conv2d produces only a depth-wise convolution layer
A 4-D tensor of size [batch, height_out, width_out, channels] with
the convolution output.
A 4 - D tensor of size [ batch height_out width_out channels ] with the convolution output .
output
inputs
A 4-D tensor of size [batch, height_in, width_in, channels].
A 4 - D tensor of size [ batch height_in width_in channels ] .
kernel_size
An int with the kernel_size of the filters.
An int with the kernel_size of the filters .
stride
An integer, the output stride.
An integer the output stride .
rate
An integer, rate for atrous convolution.
An integer rate for atrous convolution .
scope
None