Theano conv2d的border_mode

文档是这么写的:

    border_mode: str, int or tuple of two int
Either of the following: ``'valid'``: apply filter wherever it completely overlaps with the
input. Generates output of shape: input shape - filter shape + 1
``'full'``: apply filter wherever it partly overlaps with the input.
Generates output of shape: input shape + filter shape - 1
``'half'``: pad input with a symmetric border of ``filter rows // 2``
rows and ``filter columns // 2`` columns, then perform a valid
convolution. For filters with an odd number of rows and columns, this
leads to the output shape being equal to the input shape.
``int``: pad input with a symmetric border of zeros of the given
width, then perform a valid convolution.
``(int1, int2)``: pad input with a symmetric border of ``int1`` rows
and ``int2`` columns, then perform a valid convolution.

首先, 这几种模式对应的padding都是zero-padding.

  • int, (int1, int2): 它们最容易理解的: 手动指定行和列方向上的padding数量.
  • valid: 其实就是不padding, 即\(border\_mode = (0, 0)\)

    Theano conv2d的border_mode
  • full: 它的padding为:\(border\_mode=(k_h-1, k_w-1)\), 其中\(k\)为kernel的行数(高)与列数(宽). 若\(k_h=k_w=3\), conv操作会全方位覆盖所有的\((3, 3)\), \((3, 1)\), \((2,1)\), \((1, 1)\)区域. 这也是它叫full的原因.

    Theano conv2d的border_mode
  • half: \(border\_mode = (\frac {(k-1)}{2}, \frac{k-1}{2})\). 注意, \(k\)一般都是奇数. full模式的padding得到的conv输出比输入要大, 而half的输出形状与输入相同. 也有叫same的.

    Theano conv2d的border_mode

* 原始图片来源: https://github.com/vdumoulin/conv_arithmetic
* Reference: http://deeplearning.net/software/theano_versions/dev/tutorial/conv_arithmetic.html
上一篇:Vue项目之实现登录功能的表单验证!


下一篇:模拟eval