diff --git a/docs/programming_guide/source_zh_cn/initializer.ipynb b/docs/programming_guide/source_zh_cn/initializer.ipynb index b70044f5ea4e749f7fc9fb088a84d0352181db0b..95a49e8948021d40132206abd569bac46c6e054a 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 a weight initialization module, which allows users to initialize network parameters by encapsulating operators and initializer methods to call strings, initializer subclasses, or custom Tensors. The Initializer class is the basic data structure used for initialization in MindSpore. Its subclasses contain several different types of data distribution (Zero, One, XavierUniform, Heuniform, Henormal, Constant, Uniform, Normal, TruncatedNormal). The following two parameter initialization modes, encapsulation operator and initializer method, are introduced in detail。" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "## 使用封装算子对参数初始化 \n", - "MindSpore提供了多种参数初始化的方式,并在部分算子中封装了参数初始化的功能。本节将介绍带有参数初始化功能的算子对参数进行初始化的方法,以`Conv2d`算子为例,分别介绍以字符串,`Initializer`子类和自定义`Tensor`等方式对网络中的参数进行初始化,以下代码示例中均以`Initializer`的子类`Normal`为例,代码示例中`Normal`均可替换成`Initializer`子类中任何一个。" + "## Parameters are initialized using an encapsulation operator \n", + "Mindspore provides a variety of parameter initialization methods, and encapsulates parameter initialization functions in some operators. This section will introduce the method of initialization of parameters by operators with parameter initialization function. Taking 'conv2D' operator as an example, it will introduce the initialization of parameters in the network by strings, subclasses of 'Initializer' and custom 'Tensor', etc. In the following code examples, the subclass 'Normal' of 'Initializer' is used as an example. In the code example, 'Normal' can be replaced by any of the subclasses of 'Initializer'。" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### 字符串 \n", - "使用字符串对网络参数进行初始化,字符串的内容需要与`Initializer`子类的名称保持一致,使用字符串方式进行初始化将使用`Initializer`子类中的默认参数,例如使用字符串`Normal`等同于使用`Initializer`的子类`Normal()`,代码样例如下:" + "### String \n", + "Network parameters are initialized using a string. The content of the string needs to be the same as the name of the 'Initializer' subclass. The default parameters in the 'Initializer' subclass are used for initialization using a string. For example, using the string 'Normal' is equivalent to using the subclass 'Normal()' of 'Initializer'. The code sample is shown below:" ] }, { @@ -93,8 +93,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### Initializer子类 \n", - "使用`Initializer`子类对网络参数进行初始化,与使用字符串对参数进行初始化的效果类似,不同的是使用字符串进行参数初始化是使用`Initializer`子类的默认参数,如要使用`Initializer`子类中的参数,就必须使用`Initializer`子类的方式对参数进行初始化,以`Normal(0.2)`为例,代码样例如下:" + "### Initializer subclass \n", + "Using the 'Initializer' subclass to initialize network parameters is similar to using a string to initialize parameters. The difference is that using a string to initialize parameters is the default parameter for using the 'Initializer' subclass. If you want to use the parameters in the 'Initializer' subclass, You must use the 'Initializer' subclass to initialize the parameter. Take 'Normal(0.2)' as an example. The code sample is as follows:" ] }, { @@ -157,8 +157,8 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 自定义的Tensor \n", - "除上述两种初始化方法外,当网络要使用MindSpore中没有的数据类型对参数进行初始化,用户可以通过自定义`Tensor`的方式来对参数进行初始化,代码样例如下:" + "### The custom of Tensor \n", + "In addition to the above two initialization methods, when the network uses data types not available in MindSpore to initialize the parameters, users can customize 'Tensor' to initialize the parameters, as shown in the code sample below:" ] }, { @@ -207,33 +207,33 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "## 使用initializer方法对参数初始化\n", + "## The parameters are initialized using the initializer method\n", "\n", - "在上述代码样例中,给出了如何在网络中进行参数初始化的方法,如在网络中使用nn层封装`Conv2d`算子,参数`weight_init`作为要初始化的数据类型传入`Conv2d`算子,算子会在初始化时通过调用`Parameter`类,进而调用封装在`Parameter`类中的`initializer`方法来完成对参数的初始化。然而有一些算子并没有像`Conv2d`那样在内部对参数初始化的功能进行封装,如`Conv3d`算子的权重就是作为参数传入`Conv3d`算子,此时就需要手动的定义权重的初始化。\n", + "In the above code sample, the method of Parameter initialization in the network is given. For example, NN layer is used to encapsulate 'conv2D' operator in the network, Parameter 'weight_init' is passed into 'conv2D' operator as the data type to be initialized, and the operator will be initialized by calling 'Parameter' class. Then the 'initializer' method encapsulated in the 'Parameter' class is called to complete the initialization of the parameters. However, some operators do not encapsulate the function of parameter initialization internally like 'conv2D'. For example, the weight of 'conv3D' operator is passed into 'conv3D' operator as parameter. In this case, it is necessary to define the initialization of weight manually。\n", "\n", - "当对参数进行初始化时,可以使用`initializer`方法调用`Initializer`子类中不同的数据类型来对参数进行初始化,进而产生不同类型的数据。\n", + "When the parameter is initialized, 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 the Initializer for parameter initialization, the parameters that are passed in are supported`init`、`shape`、`dtype`:\n", "\n", - "- `init`:支持传入`Tensor`、 `str`、 `Initializer的子类`。\n", + "- `init`:Support the incoming`Tensor`、 `str`、 `A subclass of Initializer`。\n", "\n", - "- `shape`:支持传入`list`、 `tuple`、 `int`。\n", + "- `shape`:Support the incoming`list`、 `tuple`、 `int`。\n", "\n", - "- `dtype`:支持传入`mindspore.dtype`。" + "- `dtype`:Support the incoming`mindspore.dtype`。" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "### init参数为Tensor" + "### The init parameter is Tensor" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "代码样例如下:" + "The code sample is shown below:" ] }, { @@ -268,7 +268,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "输出如下:\n", + "The output is as follows:\n", "\n", "```text\n", "[[[[[108 108 108 ... 108 108 108]\n", @@ -293,14 +293,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### init参数为str" + "### The init parameter is STR" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "代码样例如下:" + "The code sample is shown below:" ] }, { @@ -329,7 +329,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "输出如下:\n", + "The output is as follows:\n", "\n", "```text\n", "[[[[[0 0 0 ... 0 0 0]\n", @@ -354,14 +354,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### init参数为Initializer子类" + "### The init parameter is a subclass of Initializer" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "代码样例如下:" + "The code sample is shown below:" ] }, { @@ -413,14 +413,14 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "### 在Parameter中的应用" + "### Application in Parameter" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ - "代码样例如下:" + "The code sample is shown below:" ] }, {