Skip to content

Latest commit

 

History

History
249 lines (201 loc) · 7.04 KB

links.rst

File metadata and controls

249 lines (201 loc) · 7.04 KB

Link and Chains

chainer.links

Chainer provides many ~chainer.Link implementations in the chainer.links package.

Note

Some of the links are originally defined in the chainer.functions namespace. They are still left in the namespace for backward compatibility, though it is strongly recommended that you use them via the chainer.links package.

Learnable connections

chainer.links.Bias chainer.links.Bilinear chainer.links.ChildSumTreeLSTM chainer.links.Convolution1D chainer.links.Convolution2D chainer.links.Convolution3D chainer.links.ConvolutionND chainer.links.Deconvolution1D chainer.links.Deconvolution2D chainer.links.Deconvolution3D chainer.links.DeconvolutionND chainer.links.DeformableConvolution2D chainer.links.DepthwiseConvolution2D chainer.links.DilatedConvolution2D chainer.links.EmbedID chainer.links.GRU chainer.links.Highway chainer.links.Inception chainer.links.InceptionBN chainer.links.Linear chainer.links.LocalConvolution2D chainer.links.LSTM chainer.links.MLPConvolution2D chainer.links.NaryTreeLSTM chainer.links.NStepBiGRU chainer.links.NStepBiLSTM chainer.links.NStepBiRNNReLU chainer.links.NStepBiRNNTanh chainer.links.NStepGRU chainer.links.NStepLSTM chainer.links.NStepRNNReLU chainer.links.NStepRNNTanh chainer.links.Parameter chainer.links.Scale chainer.links.StatefulGRU chainer.links.StatelessGRU chainer.links.StatefulMGU chainer.links.StatelessMGU chainer.links.StatefulPeepholeLSTM chainer.links.StatefulZoneoutLSTM chainer.links.StatelessLSTM

Activation/loss/normalization functions with parameters

chainer.links.BatchNormalization chainer.links.BatchRenormalization chainer.links.DecorrelatedBatchNormalization chainer.links.GroupNormalization chainer.links.LayerNormalization chainer.links.BinaryHierarchicalSoftmax chainer.links.BlackOut chainer.links.CRF1d chainer.links.SimplifiedDropconnect chainer.links.PReLU chainer.links.Swish chainer.links.Maxout chainer.links.NegativeSampling

Machine learning models

chainer.links.Classifier

Pre-trained models

Pre-trained models are mainly used to achieve a good performance with a small dataset, or extract a semantic feature vector. Although CaffeFunction automatically loads a pre-trained model released as a caffemodel, the following link models provide an interface for automatically converting caffemodels, and easily extracting semantic feature vectors.

For example, to extract the feature vectors with VGG16Layers, which is a common pre-trained model in the field of image recognition, users need to write the following few lines:

from chainer.links import VGG16Layers
from PIL import Image

model = VGG16Layers()
img = Image.open("path/to/image.jpg")
feature = model.extract([img], layers=["fc7"])["fc7"]

where fc7 denotes a layer before the last fully-connected layer. Unlike the usual links, these classes automatically load all the parameters from the pre-trained models during initialization.

VGG Networks

chainer.links.VGG16Layers chainer.links.VGG19Layers chainer.links.model.vision.vgg.prepare

Note

ChainerCV contains implementation of VGG networks as well (i.e., chainercv.links.model.vgg.VGG16). Unlike the Chainer's implementation, the ChainerCV's implementation assumes the color channel of the input image to be ordered in RGB instead of BGR.

GoogLeNet

chainer.links.GoogLeNet chainer.links.model.vision.googlenet.prepare

Residual Networks

chainer.links.model.vision.resnet.ResNetLayers chainer.links.ResNet50Layers chainer.links.ResNet101Layers chainer.links.ResNet152Layers chainer.links.model.vision.resnet.prepare

Note

ChainerCV contains implementation of ResNet as well (i.e., chainercv.links.model.resnet.ResNet50, chainercv.links.model.resnet.ResNet101, chainercv.links.model.resnet.ResNet152). Unlike the Chainer's implementation, the ChainerCV's implementation assumes the color channel of the input image to be ordered in RGB instead of BGR.

ChainerCV models

Note

ChainerCV supports implementations of links that are useful for computer vision problems, such as object detection, semantic segmentation, and instance segmentation. The documentation can be found in chainercv.links. Here is a subset of models with pre-trained weights supported by ChainerCV:

  • Detection
    • chainercv.links.model.faster_rcnn.FasterRCNNVGG16
    • chainercv.links.model.ssd.SSD300
    • chainercv.links.model.ssd.SSD512
    • chainercv.links.model.yolo.YOLOv2
    • chainercv.links.model.yolo.YOLOv3
  • Semantic Segmentation
    • chainercv.links.model.segnet.SegNetBasic
    • chainercv.experimental.links.model.pspnet.PSPNetResNet101
  • Instance Segmentation
    • chainercv.experimental.links.model.fcis.FCISResNet101
  • Classification
    • chainercv.links.model.resnet.ResNet101
    • chainercv.links.model.resnet.ResNet152
    • chainercv.links.model.resnet.ResNet50
    • chainercv.links.model.senet.SEResNet101
    • chainercv.links.model.senet.SEResNet152
    • chainercv.links.model.senet.SEResNet50
    • chainercv.links.model.senet.SEResNeXt101
    • chainercv.links.model.senet.SEResNeXt50
    • chainercv.links.model.vgg.VGG16

Compatibility with other frameworks

chainer.links.TheanoFunction chainer.links.caffe.CaffeFunction

chainer

chainer.Link chainer.Chain chainer.ChainList chainer.Sequential

chainer.link_hooks

Chainer provides a link-hook mechanism that enriches the behavior of ~chainer.Link.

chainer

chainer.link_hooks.SpectralNormalization chainer.link_hooks.TimerHook chainer.link_hooks.WeightStandardization

You can also implement your own link-hook to inject arbitrary code before/after the forward propagation.

chainer

chainer.LinkHook