From 33a569260371b4c5ef0c97a12c5d2c5423222773 Mon Sep 17 00:00:00 2001 From: niboshi Date: Tue, 5 Sep 2017 13:42:47 +0900 Subject: [PATCH] doc: Initializer criteria --- chainer/links/connection/linear.py | 13 +++++-------- docs/source/reference/initializers.rst | 21 +++++++++++++++++---- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/chainer/links/connection/linear.py b/chainer/links/connection/linear.py index fd5a7d4dd8f8..6ebda63993e9 100644 --- a/chainer/links/connection/linear.py +++ b/chainer/links/connection/linear.py @@ -24,14 +24,11 @@ class Linear(link.Link): data pass at which time the size will be determined. out_size (int): Dimension of output vectors. nobias (bool): If ``True``, then this function does not use the bias. - initialW (2-D array): Initial weight value. If ``None``, then the - default initializer is used. - May also be a callable that takes ``numpy.ndarray`` or - ``cupy.ndarray`` and edits its value. - initial_bias (1-D array): Initial bias value. If ``None``, the bias - vector is initialized to zero. - May also be a callable that takes ``numpy.ndarray`` or - ``cupy.ndarray`` and edits its value. + initialW (:ref:`initializer `): Initializer to initialize + the weight. + initial_bias (:ref:`initializer `): Initializer to + initialize the bias. If ``None``, the bias will be initialized to + zero. .. seealso:: :func:`~chainer.functions.linear` Attributes: diff --git a/docs/source/reference/initializers.rst b/docs/source/reference/initializers.rst index 464eaa4e2938..05a72e65671c 100644 --- a/docs/source/reference/initializers.rst +++ b/docs/source/reference/initializers.rst @@ -1,10 +1,23 @@ +.. _initializer: + Weight Initializers =================== -Weight initializer is an instance of :class:`~chainer.Initializer` that -destructively edits the contents of :class:`numpy.ndarray` or :class:`cupy.ndarray`. -Typically, weight initializers are passed to ``__init__`` of :class:`~chainer.Link` -and initializes its the weights and biases. +Weight initializers are used to initialize arrays. +They destructively modify the content of :class:`numpy.ndarray` +or :class:`cupy.ndarray`. +Typically, weight initializers are passed to :class:`~chainer.Link`\ s +to initialize their weights and biases. + +A weight initializer can be any of the following objects. + +* :class:`chainer.Initializer` class instance. +* Python or NumPy scalar. +* A callable that takes an array (:class:`numpy.ndarray` or :class:`cupy.ndarray`) + and feeds the initial data into it. +* ``None``, in which case *the default initializer* is used. + Unless explicitly specified, it is :class:`~chainer.initializers.LeCunNormal` + with scale value 1. Base class ----------