diff --git a/docs/programming_guide/source_zh_cn/initializer.ipynb b/docs/programming_guide/source_zh_cn/initializer.ipynb index b70044f5ea4e749f7fc9fb088a84d0352181db0b..2ccef016ad425e52ff61ec023b11390401155152 100644 --- a/docs/programming_guide/source_zh_cn/initializer.ipynb +++ b/docs/programming_guide/source_zh_cn/initializer.ipynb @@ -4,7 +4,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# 网络参数的初始化\n", + "# Initialization of Network Parameters\n", "\n", "[![](https://gitee.com/mindspore/docs/raw/master/resource/_static/logo_source.png)](https://gitee.com/mindspore/docs/blob/master/docs/programming_guide/source_zh_cn/initializer.ipynb) [![](https://gitee.com/mindspore/docs/raw/master/resource/_static/logo_notebook.png)](https://obs.dualstack.cn-north-4.myhuaweicloud.com/mindspore-website/notebook/master/programming_guide/mindspore_initializer.ipynb) [![](https://gitee.com/mindspore/docs/raw/master/resource/_static/logo_modelarts.png)](https://authoring-modelarts-cnnorth4.huaweicloud.com/console/lab?share-url-b64=aHR0cHM6Ly9vYnMuZHVhbHN0YWNrLmNuLW5vcnRoLTQubXlodWF3ZWljbG91ZC5jb20vbWluZHNwb3JlLXdlYnNpdGUvbm90ZWJvb2svbW9kZWxhcnRzL3Byb2dyYW1taW5nX2d1aWRlL21pbmRzcG9yZV9pbml0aWFsaXplci5pcHluYg==&imagename=MindSpore1.1.1)" ] @@ -13,25 +13,25 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 概述\n", + "## Overview\n", "\n", - "MindSpore提供了权重初始化模块,用户可以通过封装算子和initializer方法来调用字符串、Initializer子类或自定义Tensor等方式完成对网络参数进行初始化。Initializer类是MindSpore中用于进行初始化的基本数据结构,其子类包含了几种不同类型的数据分布(Zero,One,XavierUniform,HeUniform,HeNormal,Constant,Uniform,Normal,TruncatedNormal)。下面针对封装算子和initializer方法两种参数初始化模式进行详细介绍。" + "MindSpore provides modules for weight initialization, users can call string, Initializer's subclasses or customized Tensor and so on by encapsulation operator and initializer method to initialize the network parameters. The Initializer class is the basic data structure for initialization in MindSpore. Its subclasses include several different types of data distribution (Zero, One, XavierUniform, Heuniform, Henormal, Constant, Uniform, Normal, TruncatedNormal). The following is the detailed introduction for 2 parameter initialization modes of encapsulation operator and initializer method." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## 使用封装算子对参数初始化 \n", - "MindSpore提供了多种参数初始化的方式,并在部分算子中封装了参数初始化的功能。本节将介绍带有参数初始化功能的算子对参数进行初始化的方法,以`Conv2d`算子为例,分别介绍以字符串,`Initializer`子类和自定义`Tensor`等方式对网络中的参数进行初始化,以下代码示例中均以`Initializer`的子类`Normal`为例,代码示例中`Normal`均可替换成`Initializer`子类中任何一个。" + "## using encapsulation operator to initialize parameters \n", + "Mindspore provides lots of methods for parameter initialization, and encapsulates parameter initialization functions in some operators. This section introduces the method for parameters initializating by operators with parameter initialization function. Taking `Conv2d` operator as an example, it introduces the initialization of parameters in the network by strings, `Initializer`'s subclasses and customized `Tensor`, etc. The following codes all using the `Initializer`'s subclass `Normal` as examples, `Normal` can be replaced by any of the subclasses of `Initializer`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### 字符串 \n", - "使用字符串对网络参数进行初始化,字符串的内容需要与`Initializer`子类的名称保持一致,使用字符串方式进行初始化将使用`Initializer`子类中的默认参数,例如使用字符串`Normal`等同于使用`Initializer`的子类`Normal()`,代码样例如下:" + "### String \n", + "When using string to initialize the network parameters, the string content needs to be the same as the name of the `Initializer` subclass. The default parameters in the `Initializer` subclass are used for string initializating. For instance, using the string `Normal` is equivalent to using the subclass `Normal()` of `Initializer`. The code sample is as follows:" ] }, { @@ -93,8 +93,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Initializer子类 \n", - "使用`Initializer`子类对网络参数进行初始化,与使用字符串对参数进行初始化的效果类似,不同的是使用字符串进行参数初始化是使用`Initializer`子类的默认参数,如要使用`Initializer`子类中的参数,就必须使用`Initializer`子类的方式对参数进行初始化,以`Normal(0.2)`为例,代码样例如下:" + "### Initializer's subclass \n", + "Using `Initializer`'s subclass to initialize the network parameter is similar to using string to do so. The difference is that using a string for parameter initialization uses the default parameters of the `Initializer` subclass. If you want to use parameters in the `Initializer` subclass, you have to use the `Initializer` subclass to initialize the parameters. Take `Normal(0.2)` as an example, code example as follows:" ] }, { @@ -157,8 +157,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 自定义的Tensor \n", - "除上述两种初始化方法外,当网络要使用MindSpore中没有的数据类型对参数进行初始化,用户可以通过自定义`Tensor`的方式来对参数进行初始化,代码样例如下:" + "### Customized Tensor \n", + "In addition to the above two initialization methods, users can initialize the parameters by customized `Tensor` when using the data type that is not in MindSpore in network. The code sample is as follows:" ] }, { @@ -207,33 +207,33 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 使用initializer方法对参数初始化\n", + "## Using initializer method to initialize parameters\n", "\n", - "在上述代码样例中,给出了如何在网络中进行参数初始化的方法,如在网络中使用nn层封装`Conv2d`算子,参数`weight_init`作为要初始化的数据类型传入`Conv2d`算子,算子会在初始化时通过调用`Parameter`类,进而调用封装在`Parameter`类中的`initializer`方法来完成对参数的初始化。然而有一些算子并没有像`Conv2d`那样在内部对参数初始化的功能进行封装,如`Conv3d`算子的权重就是作为参数传入`Conv3d`算子,此时就需要手动的定义权重的初始化。\n", + "In the above code sample, the method for parameter initialization in the network is given. For example, nn layer is used to encapsulate `Conv2d` operator in the network, and the parameter `weight_init` is passed into a `Conv2d` operator as the initialized data type. When initializing, the operator will call the class of `Parameter`, then call the `initializer` method encapsulated in the class `Parameter` to initialize the parameters. However, some operators do not encapsulate the parameter initialization function internally like `Conv2d`. For example, the weights of `Conv3D` operators are passed to `Conv3D` operators as parameters. In this case, it is necessary to manually define the weight initialization.", "\n", - "当对参数进行初始化时,可以使用`initializer`方法调用`Initializer`子类中不同的数据类型来对参数进行初始化,进而产生不同类型的数据。\n", + "When initializing the parameter, the `initializer` method can be used to initialize the parameter by calling different data types in the `Initializer` subclass to produce different types of data.\n", "\n", - "使用initializer进行参数初始化时,支持传入的参数有`init`、`shape`、`dtype`:\n", + "When using initializer for parameter initialization, the parameters that support passing in are `init`, `shape`, `dtype`: \n", "\n", - "- `init`:支持传入`Tensor`、 `str`、 `Initializer的子类`。\n", + "- `init`: supports passing in `Tensor`, `str`, `Initializer`'s subclass.\n", "\n", - "- `shape`:支持传入`list`、 `tuple`、 `int`。\n", + "- `shape`: supports passing in `list`, `tuple`, `int`.\n", "\n", - "- `dtype`:支持传入`mindspore.dtype`。" + "- `dtype`: supports passing in `mindspore.dtype`." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### init参数为Tensor" + "### init's parameter is Tensor" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "代码样例如下:" + "Code example as follows: " ] }, { @@ -268,7 +268,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "输出如下:\n", + "Output as follows: \n", "\n", "```text\n", "[[[[[108 108 108 ... 108 108 108]\n", @@ -293,14 +293,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### init参数为str" + "### init's parameter is str" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "代码样例如下:" + "Code example as follows: " ] }, { @@ -329,7 +329,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "输出如下:\n", + "Output as follows: \n", "\n", "```text\n", "[[[[[0 0 0 ... 0 0 0]\n", @@ -354,14 +354,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### init参数为Initializer子类" + "### init's parameter is the subclass of Initializer" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "代码样例如下:" + "Code example as follows: " ] }, { @@ -413,14 +413,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 在Parameter中的应用" + "### Application in Parameter" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "代码样例如下:" + "Code example as follows: " ] }, {