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 to use them via the chainer.links
package.
chainer.links.Bias chainer.links.Bilinear chainer.links.ChildSumTreeLSTM chainer.links.Convolution2D chainer.links.ConvolutionND chainer.links.Deconvolution2D chainer.links.DeconvolutionND 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.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.Scale chainer.links.StatefulGRU chainer.links.StatelessGRU chainer.links.StatefulPeepholeLSTM chainer.links.StatelessLSTM
chainer.links.BatchNormalization chainer.links.LayerNormalization chainer.links.BinaryHierarchicalSoftmax chainer.links.BlackOut chainer.links.CRF1d chainer.links.SimplifiedDropconnect chainer.links.PReLU chainer.links.Maxout chainer.links.NegativeSampling
chainer.links.Classifier
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.
chainer.links.VGG16Layers chainer.links.model.vision.vgg.prepare
chainer.links.GoogLeNet chainer.links.model.vision.googlenet.prepare
chainer.links.model.vision.resnet.ResNetLayers chainer.links.ResNet50Layers chainer.links.ResNet101Layers chainer.links.ResNet152Layers chainer.links.model.vision.resnet.prepare
chainer.links.TheanoFunction chainer.links.caffe.CaffeFunction