conv.py 文件源码

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

项目:sonnet 作者: deepmind 项目源码 文件源码
def _fill_and_one_pad_stride(stride, n, data_format=DATA_FORMAT_NHWC):
  """Expands the provided stride to size n and pads it with 1s."""
  if isinstance(stride, numbers.Integral) or (
      isinstance(stride, collections.Iterable) and len(stride) <= n):
    if data_format == DATA_FORMAT_NHWC:
      return (1,) + _fill_shape(stride, n) + (1,)
    elif data_format == DATA_FORMAT_NCHW:
      return (1, 1,) + _fill_shape(stride, n)
    else:
      raise ValueError("Invalid data_format {:s}. Allowed formats "
                       "{:s}".format(data_format, SUPPORTED_DATA_FORMATS))

  elif isinstance(stride, collections.Iterable) and len(stride) == n + 2:
    return stride
  else:
    raise base.IncompatibleShapeError(
        "stride is {} ({}), must be either a positive integer or an iterable of"
        " positive integers of size {}".format(stride, type(stride), n))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号