Chainer
v5.0.0

Chainer Documents

  • Chainer at a Glance
  • Installation
  • Guides
  • Neural Net Examples
  • Reference
    • Variable and Parameter
    • Functions
    • Link and Chains
      • 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.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
        • VGG Networks
        • GoogLeNet
        • Residual Networks
        • Compatibility with other frameworks
      • Link and Chain base classes
        • chainer.Link
        • chainer.Chain
        • chainer.ChainList
        • chainer.Sequential
      • Link hooks
        • chainer.LinkHook
    • Probability Distributions
    • Optimizers
    • Weight Initializers
    • Training Tools
    • Datasets
    • Iterator
    • Serializers
    • Utilities
    • Configuring Chainer
    • Debug Mode
    • Visualization of Computational Graph
    • Static Subgraph Optimizations: Usage
    • Static Subgraph Optimizations: Design Notes
    • Caffe Model Support
    • Assertion and Testing
  • Distributed Deep Learning with ChainerMN

Other

  • API Compatibility Policy
  • Contribution Guide
  • Tips and FAQs
  • Performance Best Practices
  • Upgrade Guide
  • Comparison with Other Frameworks
  • License

Community

  • Slack Chat
  • Forums
  • Notebook Examples
  • Examples in Awesome Chainer
Chainer
  • Docs »
  • Reference »
  • Link and Chains
  • Edit on GitHub

Link and Chains¶

Chainer provides many 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 to use them via the chainer.links package.

Learnable connections¶

chainer.links.Bias Broadcasted elementwise summation with learnable parameters.
chainer.links.Bilinear Bilinear layer that performs tensor multiplication.
chainer.links.ChildSumTreeLSTM Child-Sum TreeLSTM unit.
chainer.links.Convolution1D 1-dimensional convolution layer.
chainer.links.Convolution2D Two-dimensional convolutional layer.
chainer.links.Convolution3D 3-dimensional convolution layer.
chainer.links.ConvolutionND N-dimensional convolution layer.
chainer.links.Deconvolution1D 1-dimensional deconvolution layer.
chainer.links.Deconvolution2D Two dimensional deconvolution function.
chainer.links.Deconvolution3D 3-dimensional deconvolution layer.
chainer.links.DeconvolutionND N-dimensional deconvolution function.
chainer.links.DeformableConvolution2D Two-dimensional deformable convolutional layer.
chainer.links.DepthwiseConvolution2D Two-dimensional depthwise convolutional layer.
chainer.links.DilatedConvolution2D Two-dimensional dilated convolutional layer.
chainer.links.EmbedID Efficient linear layer for one-hot input.
chainer.links.GRU Stateful Gated Recurrent Unit function (GRU)
chainer.links.Highway Highway module.
chainer.links.Inception Inception module of GoogLeNet.
chainer.links.InceptionBN Inception module of the new GoogLeNet with BatchNormalization.
chainer.links.Linear Linear layer (a.k.a. fully-connected layer).
chainer.links.LocalConvolution2D Two-dimensional local convolutional layer.
chainer.links.LSTM Fully-connected LSTM layer.
chainer.links.MLPConvolution2D Two-dimensional MLP convolution layer of Network in Network.
chainer.links.NaryTreeLSTM N-ary TreeLSTM unit.
chainer.links.NStepBiGRU Stacked Bi-directional GRU for sequences.
chainer.links.NStepBiLSTM Stacked Bi-directional LSTM for sequences.
chainer.links.NStepBiRNNReLU Stacked Bi-directional RNN for sequences.
chainer.links.NStepBiRNNTanh Stacked Bi-directional RNN for sequences.
chainer.links.NStepGRU Stacked Uni-directional GRU for sequences.
chainer.links.NStepLSTM Stacked Uni-directional LSTM for sequences.
chainer.links.NStepRNNReLU Stacked Uni-directional RNN for sequences.
chainer.links.NStepRNNTanh Stacked Uni-directional RNN for sequences.
chainer.links.Parameter Link that just holds a parameter and returns it.
chainer.links.Scale Broadcasted elementwise product with learnable parameters.
chainer.links.StatefulGRU Stateful Gated Recurrent Unit function (GRU).
chainer.links.StatelessGRU Stateless Gated Recurrent Unit function (GRU).
chainer.links.StatefulMGU
chainer.links.StatelessMGU
chainer.links.StatefulPeepholeLSTM Fully-connected LSTM layer with peephole connections.
chainer.links.StatefulZoneoutLSTM
chainer.links.StatelessLSTM Stateless LSTM layer.

Activation/loss/normalization functions with parameters¶

chainer.links.BatchNormalization Batch normalization layer on outputs of linear or convolution functions.
chainer.links.BatchRenormalization Batch renormalization layer on outputs of linear or convolution functions.
chainer.links.GroupNormalization Group normalization layer on outputs of convolution functions.
chainer.links.LayerNormalization Layer normalization layer on outputs of linear functions.
chainer.links.BinaryHierarchicalSoftmax Hierarchical softmax layer over binary tree.
chainer.links.BlackOut BlackOut loss layer.
chainer.links.CRF1d Linear-chain conditional random field loss layer.
chainer.links.SimplifiedDropconnect Fully-connected layer with simplified dropconnect regularization.
chainer.links.PReLU Parametric ReLU function as a link.
chainer.links.Swish Swish activation function as a link.
chainer.links.Maxout Fully-connected maxout layer.
chainer.links.NegativeSampling Negative sampling loss layer.

Machine learning models¶

chainer.links.Classifier A simple classifier model.

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 A pre-trained CNN model with 16 layers provided by VGG team.
chainer.links.VGG19Layers A pre-trained CNN model with 19 layers provided by VGG team.
chainer.links.model.vision.vgg.prepare Converts the given image to the numpy array for VGG models.

GoogLeNet¶

chainer.links.GoogLeNet A pre-trained GoogLeNet model provided by BVLC.
chainer.links.model.vision.googlenet.prepare Converts the given image to the numpy array for GoogLeNet.

Residual Networks¶

chainer.links.model.vision.resnet.ResNetLayers A pre-trained CNN model provided by MSRA.
chainer.links.ResNet50Layers A pre-trained CNN model with 50 layers provided by MSRA.
chainer.links.ResNet101Layers A pre-trained CNN model with 101 layers provided by MSRA.
chainer.links.ResNet152Layers A pre-trained CNN model with 152 layers provided by MSRA.
chainer.links.model.vision.resnet.prepare Converts the given image to the numpy array for ResNets.

Compatibility with other frameworks¶

chainer.links.TheanoFunction Theano function wrapper.
chainer.links.caffe.CaffeFunction Caffe emulator based on the model file of Caffe.

Link and Chain base classes¶

chainer.Link Building block of model definitions.
chainer.Chain Composable link with object-like interface.
chainer.ChainList Composable link with list-like interface.
chainer.Sequential Sequential model which has a single-stream forward pass.

Link hooks¶

Chainer provides a link-hook mechanism that enriches the behavior of Link. You can implement your own link-hook to inject arbitrary code before/after the forward propagation.

chainer.LinkHook Base class of hooks for links.
Next Previous

© Copyright 2015, Preferred Networks, inc. and Preferred Infrastructure, inc. Revision e4a0b8fc.

Built with Sphinx using a theme provided by Read the Docs.