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 that you use them via the chainer.links
package.
Learnable connections¶
Broadcasted elementwise summation with learnable parameters. |
|
Bilinear layer that performs tensor multiplication. |
|
Child-Sum TreeLSTM unit. |
|
1-dimensional convolution layer. |
|
Two-dimensional convolutional layer. |
|
3-dimensional convolution layer. |
|
N-dimensional convolution layer. |
|
1-dimensional deconvolution layer. |
|
Two dimensional deconvolution function. |
|
3-dimensional deconvolution layer. |
|
N-dimensional deconvolution function. |
|
Two-dimensional deformable convolutional layer. |
|
Two-dimensional depthwise convolutional layer. |
|
Two-dimensional dilated convolutional layer. |
|
Efficient linear layer for one-hot input. |
|
Stateful Gated Recurrent Unit function (GRU) |
|
Highway module. |
|
Inception module of GoogLeNet. |
|
Inception module of the new GoogLeNet with BatchNormalization. |
|
Linear layer (a.k.a. fully-connected layer). |
|
Two-dimensional local convolutional layer. |
|
Fully-connected LSTM layer. |
|
Two-dimensional MLP convolution layer of Network in Network. |
|
N-ary TreeLSTM unit. |
|
Stacked Bi-directional GRU for sequences. |
|
Stacked Bi-directional LSTM for sequences. |
|
Stacked Bi-directional RNN for sequences. |
|
Stacked Bi-directional RNN for sequences. |
|
Stacked Uni-directional GRU for sequences. |
|
Stacked Uni-directional LSTM for sequences. |
|
Stacked Uni-directional RNN for sequences. |
|
Stacked Uni-directional RNN for sequences. |
|
Link that just holds a parameter and returns it. |
|
Broadcasted elementwise product with learnable parameters. |
|
Stateful Gated Recurrent Unit function (GRU). |
|
Stateless Gated Recurrent Unit function (GRU). |
|
Fully-connected LSTM layer with peephole connections. |
|
Stateless LSTM layer. |
Activation/loss/normalization functions with parameters¶
Batch normalization layer on outputs of linear or convolution functions. |
|
Batch renormalization layer on outputs of linear or convolution functions. |
|
Decorrelated batch normalization layer. |
|
Group normalization layer on outputs of convolution functions. |
|
Layer normalization layer on outputs of linear functions. |
|
Hierarchical softmax layer over binary tree. |
|
BlackOut loss layer. |
|
Linear-chain conditional random field loss layer. |
|
Fully-connected layer with simplified dropconnect regularization. |
|
Parametric ReLU function as a link. |
|
Swish activation function as a link. |
|
Fully-connected maxout layer. |
|
Negative sampling loss layer. |
Machine learning models¶
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¶
A pre-trained CNN model with 16 layers provided by VGG team. |
|
A pre-trained CNN model with 19 layers provided by VGG team. |
|
Converts the given image to the numpy array for VGG models. |
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¶
A pre-trained GoogLeNet model provided by BVLC. |
|
Converts the given image to the numpy array for GoogLeNet. |
Residual Networks¶
A pre-trained CNN model provided by MSRA. |
|
A pre-trained CNN model with 50 layers provided by MSRA. |
|
A pre-trained CNN model with 101 layers provided by MSRA. |
|
A pre-trained CNN model with 152 layers provided by MSRA. |
|
Converts the given image to a numpy array for ResNet. |
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:
- Instance Segmentation
- Classification
Compatibility with other frameworks¶
Theano function wrapper. |
|
Caffe emulator based on the model file of Caffe. |
Link and Chain base classes¶
Building block of model definitions. |
|
Composable link with object-like interface. |
|
Composable link with list-like interface. |
|
Sequential model which has a single-stream forward pass. |
Link hooks¶
Chainer provides a link-hook mechanism that enriches the behavior of Link
.
Spectral Normalization link hook implementation. |
|
Link hook for measuring elapsed time of |
You can also implement your own link-hook to inject arbitrary code before/after the forward propagation.
Base class of hooks for links. |