Standard Link implementations¶
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.Convolution2D |
Two-dimensional convolutional layer. |
chainer.links.ConvolutionND |
N-dimensional convolution layer. |
chainer.links.Deconvolution2D |
Two dimensional deconvolution function. |
chainer.links.DeconvolutionND |
N-dimensional deconvolution function. |
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.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 sequnces. |
chainer.links.NStepBiLSTM |
Stacked Bi-directional LSTM for sequnces. |
chainer.links.NStepBiRNNReLU |
Stacked Bi-directional RNN for sequnces. |
chainer.links.NStepBiRNNTanh |
Stacked Bi-directional RNN for sequnces. |
chainer.links.NStepGRU |
Stacked Uni-directional GRU for sequnces. |
chainer.links.NStepLSTM |
Stacked Uni-directional LSTM for sequnces. |
chainer.links.NStepRNNReLU |
Stacked Uni-directional RNN for sequnces. |
chainer.links.NStepRNNTanh |
Stacked Uni-directional RNN for sequnces. |
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.StatefulPeepholeLSTM |
Fully-connected LSTM layer with peephole connections. |
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.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.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.
VGG16Layers¶
chainer.links.VGG16Layers |
A pre-trained CNN model with 16 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. |