ResNet

Utility

Bottleneck

class chainercv.links.model.resnet.Bottleneck(in_channels, mid_channels, out_channels, stride=1, dilate=1, groups=1, initialW=None, bn_kwargs={}, residual_conv=False, stride_first=False, add_seblock=False)[source]

A bottleneck layer.

Parameters
  • in_channels (int) – The number of channels of the input array.

  • mid_channels (int) – The number of channels of intermediate arrays.

  • out_channels (int) – The number of channels of the output array.

  • stride (int or tuple of ints) – Stride of filter application.

  • dilate (int or tuple of ints) – Dilation factor of filter applications. dilate=d and dilate=(d, d) are equivalent.

  • groups (int) – The number of groups to use grouped convolution in the second layer. The default is one, where grouped convolution is not used.

  • initialW (callable) – Initial weight value used in the convolutional layers.

  • bn_kwargs (dict) – Keyword arguments passed to initialize chainer.links.BatchNormalization.

  • residual_conv (bool) – If True, apply a 1x1 convolution to the residual.

  • stride_first (bool) – If True, apply strided convolution with the first convolution layer. Otherwise, apply strided convolution with the second convolution layer.

  • add_seblock (bool) – If True, apply a squeeze-and-excitation block to each residual block.

ResBlock

class chainercv.links.model.resnet.ResBlock(n_layer, in_channels, mid_channels, out_channels, stride, dilate=1, groups=1, initialW=None, bn_kwargs={}, stride_first=False, add_seblock=False)[source]

A building block for ResNets.

in –> Bottleneck with residual_conv –> Bottleneck * (n_layer - 1) –> out

Parameters
  • n_layer (int) – The number of layers used in the building block.

  • in_channels (int) – The number of channels of the input array.

  • mid_channels (int) – The number of channels of intermediate arrays.

  • out_channels (int) – The number of channels of the output array.

  • stride (int or tuple of ints) – Stride of filter application.

  • dilate (int or tuple of ints) – Dilation factor of filter applications. dilate=d and dilate=(d, d) are equivalent.

  • groups (int) – The number of groups to use grouped convolution in the second layer of each bottleneck. The default is one, where grouped convolution is not used.

  • initialW (callable) – Initial weight value used in the convolutional layers.

  • bn_kwargs (dict) – Keyword arguments passed to initialize chainer.links.BatchNormalization.

  • stride_first (bool) – This determines the behavior of the bottleneck with a shortcut. If True, apply strided convolution with the first convolution layer. Otherwise, apply strided convolution with the second convolution layer.

  • add_seblock (bool) – If True, apply a squeeze-and-excitation block to each residual block.