Connection¶
Conv2DActiv¶
-
class
chainercv.links.connection.
Conv2DActiv
(in_channels, out_channels, ksize=None, stride=1, pad=0, dilate=1, 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 foractiv
.Example
There are sevaral ways to initialize a
Conv2DActiv
.Give the first three arguments explicitly:
>>> l = Conv2DActiv(5, 10, 3)
Omit
in_channels
or fill it withNone
: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 tuple of ints) – Size of filters (a.k.a. kernels).
ksize=k
andksize=(k, k)
are equivalent. - stride (int or tuple of ints) – Stride of filter applications.
stride=s
andstride=(s, s)
are equivalent. - pad (int or tuple of ints) – Spatial padding width for input arrays.
pad=p
andpad=(p, p)
are equivalent. - dilate (int or tuple of ints) – Dilation factor of filter applications.
dilate=d
anddilate=(d, d)
are equivalent. - nobias (bool) – If
True
, then this link does not use the bias term. - initialW (callable) – Initial weight value. If
None
, the default initializer is used. May also be a callable that takesnumpy.ndarray
orcupy.ndarray
and edits its value. - initial_bias (callable) – Initial bias value. If
None
, the bias is set to 0. May also be a callable that takesnumpy.ndarray
orcupy.ndarray
and edits its value. - activ (callable) – An activation function. The default value is
chainer.functions.relu()
. If this isNone
, no activation is applied (i.e. the activation is the identity function).
Conv2DBNActiv¶
-
class
chainercv.links.connection.
Conv2DBNActiv
(in_channels, out_channels, ksize=None, stride=1, pad=0, dilate=1, 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 foractiv
andbn_kwargs
.bn_kwargs
can includecomm
key and a communicator of ChainerMN as the value to usechainermn.links.MultiNodeBatchNormalization
. Ifcomm
is not included inbn_kwargs
,chainer.links.BatchNormalization
link from Chainer is used. Note that the default value for thenobias
is changed toTrue
.Example
There are sevaral ways to initialize a
Conv2DBNActiv
.Give the first three arguments explicitly:
>>> l = Conv2DBNActiv(5, 10, 3)
Omit
in_channels
or fill it withNone
: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 tuple of ints) – Size of filters (a.k.a. kernels).
ksize=k
andksize=(k, k)
are equivalent. - stride (int or tuple of ints) – Stride of filter applications.
stride=s
andstride=(s, s)
are equivalent. - pad (int or tuple of ints) – Spatial padding width for input arrays.
pad=p
andpad=(p, p)
are equivalent. - dilate (int or tuple of ints) – Dilation factor of filter applications.
dilate=d
anddilate=(d, d)
are equivalent. - nobias (bool) – If
True
, then this link does not use the bias term. - initialW (callable) – Initial weight value. If
None
, the default initializer is used. May also be a callable that takesnumpy.ndarray
orcupy.ndarray
and edits its value. - initial_bias (callable) – Initial bias value. If
None
, the bias is set to 0. May also be a callable that takesnumpy.ndarray
orcupy.ndarray
and edits its value. - activ (callable) – An activation function. The default value is
chainer.functions.relu()
. If this isNone
, no activation is applied (i.e. the activation is the identity function). - bn_kwargs (dict) – Keyword arguments passed to initialize
chainer.links.BatchNormalization
. If a ChainerMN communicator (CommunicatorBase) is given with the key :obj:`comm
,MultiNodeBatchNormalization
will be used for the batch normalization. Otherwise,BatchNormalization
will be used.