text: #! /usr/bin/env python3
  # coding=utf-8
  #================================================================
  #   Copyright (C) 2018 * Ltd. All rights reserved.
  #
  #   Editor      : VIM
  #   File name   : common.py
  #   Author      : YunYang1994
  #   Created date: 2018-11-20 10:22:32
  #   Description : some basical layer for daraknet53 and yolov3
  #
  #================================================================
  
  import tensorflow as tf
  slim = tf.contrib.slim
  
  def _conv2d_fixed_padding(inputs, filters, kernel_size, strides=1):
      if strides > 1: inputs = _fixed_padding(inputs, kernel_size)
      inputs = slim.conv2d(inputs, filters, kernel_size, stride=strides,
                           padding=('SAME' if strides == 1 else 'VALID'))
      return inputs
  
  
  @tf.contrib.framework.add_arg_scope
  def _fixed_padding(inputs, kernel_size, mode='CONSTANT', *args, **kwargs):
      """
      Pads the input along the spatial dimensions independently of input size.
  
      Args:
        inputs: A tensor of size [batch, channels, height_in, width_in] or
          [batch, height_in, width_in, channels] depending on data_format.
        kernel_size: The kernel to be used in the conv2d or max_pool2d operation.
                     Should be a positive integer.
        mode: The mode for tf.pad.
  
      Returns:
        A tensor with the same format as the input with the data either intact
        (if kernel_size == 1) or padded (if kernel_size > 1).
      """
      pad_total = kernel_size - 1
      pad_beg = pad_total // 2
      pad_end = pad_total - pad_beg
  
      padded_inputs = tf.pad(inputs, [[0, 0], [pad_beg, pad_end],
                                      [pad_beg, pad_end], [0, 0]], mode=mode)
      return padded_inputs
  
  