resnet_model.py 文件源码

python
阅读 30 收藏 0 点赞 0 评论 0

项目:tpu-demos 作者: tensorflow 项目源码 文件源码
def conv2d_fixed_padding(inputs, filters, kernel_size, strides):
  """Strided 2-D convolution with explicit padding.

  The padding is consistent and is based only on `kernel_size`, not on the
  dimensions of `inputs` (as opposed to using `tf.layers.conv2d` alone).

  Args:
    inputs: A Tensor of size [batch, channels, height_in, width_in].
    filters: The number of filters in the convolution.
    kernel_size: The size of the kernel to be used in the convolution.
    strides: The strides of the convolution.

  Returns:
    A Tensor of shape [batch, filters, height_out, width_out].
  """
  if strides > 1:
    inputs = fixed_padding(inputs, kernel_size)

  return tf.layers.conv2d(
      inputs=inputs, filters=filters, kernel_size=kernel_size, strides=strides,
      padding=('SAME' if strides == 1 else 'VALID'), use_bias=False,
      kernel_initializer=tf.variance_scaling_initializer(),
      data_format='channels_first')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号