A pre-trained CNN model with 16 layers provided by VGG team.
During initialization, this chain model automatically downloads
the pre-trained caffemodel, convert to another chainer model,
stores it on your local directory, and initializes all the parameters
with it. This model would be useful when you want to extract a semantic
feature vector from a given image, or fine-tune the model
on a different dataset.
Note that this pre-trained model is released under Creative Commons
If you want to manually convert the pre-trained caffemodel to a chainer
model that can be specified in the constructor,
please use convert_caffemodel_to_npz classmethod instead.
pretrained_model (str) – the destination of the pre-trained
chainer model serialized as a .npz file.
If this argument is specified as auto,
it automatically downloads the caffemodel from the internet.
Note that in this case the converted chainer model is stored
on $CHAINER_DATASET_ROOT/pfnet/chainer/models directory,
where $CHAINER_DATASET_ROOT is set as
$HOME/.chainer/dataset unless you specify another value
as a environment variable. The converted chainer model is
automatically used from the second time.
If the argument is specified as None, all the parameters
are not initialized by the pre-trained model, but the default
initializer used in the original paper, i.e.,
available_layers (list of str) – The list of available layer names
used by __call__ and extract methods.
The latter one is easier for IDEs to keep track of the attribute’s
name (str) – Name of the parameter. This name is also used as the
shape (int or tuple of ints) – Shape of the parameter array. If it
is omitted, the parameter variable is left uninitialized.
dtype – Data type of the parameter array.
initializer – If it is not None, the data is initialized with
the given initializer. If it is an array, the data is directly
initialized by it. If it is callable, it is used as a weight
initializer. Note that in these cases, dtype argument is
The difference of directly executing __call__ is that
it directly accepts images as an input and automatically
transforms them to a proper variable. That is,
it is also interpreted as a shortcut method that implicitly calls
prepare and __call__ functions.
test and volatile arguments are not supported anymore since
Instead, use chainer.using_config('train',train) and
This method returns a context manager object that enables registration
of parameters (and links for Chain) by an assignment.
A Parameter object can be automatically registered
by assigning it to an attribute under this context manager.
In most cases, the parameter registration is done in the
initializer method. Using the init_scope method, we can
simply assign a Parameter object to register
it to the link.
Registers an attribute of a given name as a persistent value.
This is a convenient method to register an existing attribute as a
persistent value. If name has been already registered as a
parameter, this method removes it from the list of parameter names
and re-registers it as a persistent value.
name (str) – Name of the attribute to be registered.