Connection

Conv2DActiv

class chainercv.links.connection.Conv2DActiv(in_channels, out_channels, ksize=None, stride=1, pad=0, nobias=False, initialW=None, initial_bias=None, activ=<function relu>)

Convolution2D –> Activation

This is a chain that does two-dimensional convolution and applies an activation.

The arguments are the same as those of chainer.links.Convolution2D except for activ.

Example

There are sevaral ways to initialize a Conv2DActiv.

  1. Give the first three arguments explicitly:

    >>> l = Conv2DActiv(5, 10, 3)
    
  2. Omit in_channels or fill it with None:

    In these ways, attributes are initialized at runtime based on the channel size of the input.

    >>> l = Conv2DActiv(10, 3)
    >>> l = Conv2DActiv(None, 10, 3)
    
Parameters:
  • in_channels (int or None) – Number of channels of input arrays. If None, parameter initialization will be deferred until the first forward data pass at which time the size will be determined.
  • out_channels (int) – Number of channels of output arrays.
  • ksize (int or pair of ints) – Size of filters (a.k.a. kernels). ksize=k and ksize=(k, k) are equivalent.
  • stride (int or pair of ints) – Stride of filter applications. stride=s and stride=(s, s) are equivalent.
  • pad (int or pair of ints) – Spatial padding width for input arrays. pad=p and pad=(p, p) are equivalent.
  • nobias (bool) – If True, then this link does not use the bias term.
  • initialW (4-D array) – Initial weight value. If None, the default initializer is used. May also be a callable that takes numpy.ndarray or cupy.ndarray and edits its value.
  • initial_bias (1-D array) – Initial bias value. If None, the bias is set to 0. May also be a callable that takes numpy.ndarray or cupy.ndarray and edits its value.
  • activ (callable) – An activation function. The default value is chainer.functions.relu().

Conv2DBNActiv

class chainercv.links.connection.Conv2DBNActiv(in_channels, out_channels, ksize=None, stride=1, pad=0, nobias=True, initialW=None, initial_bias=None, activ=<function relu>, bn_kwargs={})

Convolution2D –> Batch Normalization –> Activation

This is a chain that sequentially apllies a two-dimensional convolution, a batch normalization and an activation.

The arguments are the same as that of chainer.links.Convolution2D except for activ and bn_kwargs. Note that the default value for the nobias is changed to True.

Example

There are sevaral ways to initialize a Conv2DBNActiv.

  1. Give the first three arguments explicitly:

    >>> l = Conv2DActiv(5, 10, 3)
    
  2. Omit in_channels or fill it with None:

    In these ways, attributes are initialized at runtime based on the channel size of the input.

    >>> l = Conv2DBNActiv(10, 3)
    >>> l = Conv2DBNActiv(None, 10, 3)
    
Parameters:
  • in_channels (int or None) – Number of channels of input arrays. If None, parameter initialization will be deferred until the first forward data pass at which time the size will be determined.
  • out_channels (int) – Number of channels of output arrays.
  • ksize (int or pair of ints) – Size of filters (a.k.a. kernels). ksize=k and ksize=(k, k) are equivalent.
  • stride (int or pair of ints) – Stride of filter applications. stride=s and stride=(s, s) are equivalent.
  • pad (int or pair of ints) – Spatial padding width for input arrays. pad=p and pad=(p, p) are equivalent.
  • nobias (bool) – If True, then this link does not use the bias term.
  • initialW (4-D array) – Initial weight value. If None, the default initializer is used. May also be a callable that takes numpy.ndarray or cupy.ndarray and edits its value.
  • initial_bias (1-D array) – Initial bias value. If None, the bias is set to 0. May also be a callable that takes numpy.ndarray or cupy.ndarray and edits its value.
  • activ (callable) – An activation function. The default value is chainer.functions.relu().
  • bn_kwargs (dict) – Keyword arguments passed to initialize chainer.links.BatchNormalization.