diff --git a/docs/source_zh_cn/constraints_on_network_construction.md b/docs/source_zh_cn/constraints_on_network_construction.md
index ff628c798272c2a83e0e7ff0aee2da47dc71c65e..7b0a6658e05bb905337cf3bc547859338c04d215 100644
--- a/docs/source_zh_cn/constraints_on_network_construction.md
+++ b/docs/source_zh_cn/constraints_on_network_construction.md
@@ -26,13 +26,13 @@
## 概述
- MindSpore完成从用户源码到计算图的编译,用户源码基于Python语法编写,当前MindSpore支持将普通函数或者继承自nn.Cell的实例转换生成计算图,暂不支持将任意Python源码转换成计算图,所以对于用户源码支持的写法有所限制,主要包括语法约束和网络定义约束两方面。随着MindSpore的演进,这些约束可能会发生变化。
+ MindSpore完成从用户源码到计算图的编译,用户源码基于Python语法编写,当前MindSpore支持将普通函数或者继承自`nn.Cell`的实例转换生成计算图,暂不支持将任意Python源码转换成计算图,所以对于用户源码支持的写法有所限制,主要包括语法约束和网络定义约束两方面。随着MindSpore的演进,这些约束可能会发生变化。
## 语法约束
### 支持的Python数据类型
* Number:包括`int`、`float`、`bool`,不支持复数类型。
* String
-* List:当前只支持append方法;List的更新会拷贝生成新的List。
+* List:当前只支持`append`方法;List的更新会拷贝生成新的List。
* Tuple
* Dictionary:当前`key`只支持String类型
### MindSpore扩展数据类型
@@ -167,7 +167,7 @@
### 其他约束
-整网construct函数输入的参数以及使用ms_function装饰器修饰的函数的参数在图编译过程中会进行泛化,不能作为常量输入传给算子使用,如下例所示:
+整网`construct`函数输入的参数以及使用`ms_function`装饰器修饰的函数的参数在图编译过程中会进行泛化,不能作为常量输入传给算子使用,如下例所示:
* 错误的写法如下:
```python
class ExpandDimsTest(Cell):
@@ -181,9 +181,9 @@
input_x = Tensor(np.random.randn(2,2,2,2).astype(np.float32))
expand_dim(input_x, 0)
```
- 在示例中,ExpandDimsTest是一个只有单算子的网络,网络的输入有input_x和input_axis两个。因为ExpandDims算子的第二个输入需要是常量,这是因为在图编译过程中推导ExpandDims算子输出维度的时候需要用到,而input_axis作为网络参数输入会泛化成变量,无法确定其值,从而无法推导算子的输出维度导致图编译失败。所以在图编译阶段需要值推导的输入都应该是常量输入。在API中,这类算子需要常量输入的参数会进行说明,标注"constant input is needed"。
+ 在示例中,`ExpandDimsTest`是一个只有单算子的网络,网络的输入有`input_x`和`input_axis`两个。因为`ExpandDims`算子的第二个输入需要是常量,这是因为在图编译过程中推导ExpandDims算子输出维度的时候需要用到,而`input_axis`作为网络参数输入会泛化成变量,无法确定其值,从而无法推导算子的输出维度导致图编译失败。所以在图编译阶段需要值推导的输入都应该是常量输入。在API中,这类算子需要常量输入的参数会进行说明,标注"constant input is needed"。
-* 正确的写法是在construct函数里面对算子的常量输入直接填入需要的值或者是一个类的成员变量,如下:
+* 正确的写法是在`construct`函数里面对算子的常量输入直接填入需要的值或者是一个类的成员变量,如下:
```python
class ExpandDimsTest(Cell):
def __init__(self, axis):
diff --git a/install/mindspore_cpu_install.md b/install/mindspore_cpu_install.md
index 7cacc407ef36cf42dae674d1450f2c851fa3fc5c..ba4c8e689aac880bca8386d7e95ebcaa659d078a 100644
--- a/install/mindspore_cpu_install.md
+++ b/install/mindspore_cpu_install.md
@@ -24,7 +24,7 @@
| MindSpore master | Ubuntu 16.04(及以上) x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5
- 其他依赖项参见[requirements.txt](https://gitee.com/mindspore/mindspore/blob/master/requirements.txt) | **编译依赖:**
- [Python](https://www.python.org/downloads/) 3.7.5
- [wheel](https://pypi.org/project/wheel/) >= 0.32.0
- [GCC](https://gcc.gnu.org/releases.html) 7.3.0
- [CMake](https://cmake.org/download/) >= 3.14.1
- [patch](http://ftp.gnu.org/gnu/patch/) >= 2.5
**安装依赖:**
与可执行文件安装依赖相同 |
- Ubuntu版本为18.04时,GCC 7.3.0可以直接通过apt命令安装。
-- 在联网状态下,安装whl包时会自动下载requirements.txt中的依赖项,其余情况需自行安装。
+- 在联网状态下,安装whl包时会自动下载`requirements.txt`中的依赖项,其余情况需自行安装。
### Conda安装(可选)
@@ -71,7 +71,7 @@
bash build.sh -e cpu -z -j4
```
> - 在执行上述命令前,需保证可执行文件cmake和patch所在路径已加入环境变量PATH中。
- > - build.sh中会执行git clone获取第三方依赖库的代码,请提前确保git的网络设置正确可用。
+ > - `build.sh`中会执行`git clone`获取第三方依赖库的代码,请提前确保git的网络设置正确可用。
> - 如果编译机性能较好,可在执行中增加-j{线程数}来增加线程数量。如`bash build.sh -e cpu -z -j12`。
3. 执行如下命令安装MindSpore。
@@ -99,7 +99,7 @@
| ---------------------- | :------------------ | :----------------------------------------------------------- | :----------------------- |
| MindArmour master | Ubuntu 16.04(及以上) x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5
- MindSpore master
- 其他依赖项参见[setup.py](https://gitee.com/mindspore/mindarmour/blob/master/setup.py) | 与可执行文件安装依赖相同 |
-- 在联网状态下,安装whl包时会自动下载setup.py中的依赖项,其余情况需自行安装。
+- 在联网状态下,安装whl包时会自动下载`setup.py`中的依赖项,其余情况需自行安装。
## 安装指南
diff --git a/install/mindspore_cpu_install_en.md b/install/mindspore_cpu_install_en.md
index f8a3c44643e67466ce5f394a34848ac7968dca4f..6170254ae2690bce51e2fe5db63bbe4497088440 100644
--- a/install/mindspore_cpu_install_en.md
+++ b/install/mindspore_cpu_install_en.md
@@ -24,7 +24,7 @@ This document describes how to quickly install MindSpore on a Ubuntu system with
| MindSpore master | Ubuntu 16.04 or later x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5
- For details about other dependency items, see [requirements.txt](https://gitee.com/mindspore/mindspore/blob/master/requirements.txt). | **Compilation dependencies:**
- [Python](https://www.python.org/downloads/) 3.7.5
- [wheel](https://pypi.org/project/wheel/) >= 0.32.0
- [GCC](https://gcc.gnu.org/releases.html) 7.3.0
- [CMake](https://cmake.org/download/) >= 3.14.1
- [patch](http://ftp.gnu.org/gnu/patch/) >= 2.5
same as the executable file installation dependencies. |
- When Ubuntu version is 18.04, GCC 7.3.0 can be installed by using apt command.
-- When the network is connected, dependency items in the requirements.txt file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
+- When the network is connected, dependency items in the `requirements.txt` file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
### (Optional) Installing Conda
@@ -71,7 +71,7 @@ This document describes how to quickly install MindSpore on a Ubuntu system with
bash build.sh -e cpu -z -j4
```
> - Before running the preceding command, ensure that the paths where the executable files cmake and patch store have been added to the environment variable PATH.
- > - In the build.sh script, the git clone command will be executed to obtain the code in the third-party dependency database. Ensure that the network settings of Git are correct.
+ > - In the `build.sh` script, the `git clone` command will be executed to obtain the code in the third-party dependency database. Ensure that the network settings of Git are correct.
> - If the compiler performance is strong, you can add -j{Number of threads} in to script to increase the number of threads. For example, `bash build.sh -e cpu -z -j12`.
3. Run the following command to install MindSpore:
@@ -99,7 +99,7 @@ If you need to conduct AI model security research or enhance the security of the
| ---- | :--- | :--- | :--- |
| MindArmour master | Ubuntu 16.04 or later x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5
- MindSpore master
- For details about other dependency items, see [setup.py](https://gitee.com/mindspore/mindarmour/blob/master/setup.py). | Same as the executable file installation dependencies. |
-- When the network is connected, dependency items in the setup.py file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
+- When the network is connected, dependency items in the `setup.py` file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
## Installation Guide
diff --git a/install/mindspore_cpu_win_install.md b/install/mindspore_cpu_win_install.md
index 505b3bf6499be7b089b28b229dc0b13f5542db99..17115b19505f7ee8ed55c9697551d146a22eb7bc 100644
--- a/install/mindspore_cpu_win_install.md
+++ b/install/mindspore_cpu_win_install.md
@@ -72,7 +72,7 @@
```
> - 在执行上述命令前,需保证mingw64\bin\路径和可执行文件cmake所在路径已加入环境变量PATH中。
> - 如git没有安装在`ProgramFiles`,在执行上述命令前,需设置环境变量指定`patch.exe`的位置,如git安装在`D:\git`时,需设置`set MS_PATCH_PATH=D:\git\usr\bin`。
- > - build.bat中会执行git clone获取第三方依赖库的代码,请提前确保git的网络设置正确可用。
+ > - `build.bat`中会执行`git clone`获取第三方依赖库的代码,请提前确保git的网络设置正确可用。
> - 如果编译机性能较好,可在执行中增加-j{线程数}来增加线程数量(默认为6)。如`call build.bat 12`。
> - 在执行上述命令前,需保证已安装[Visual C++ Redistributable for Visual Studio 2015](https://www.microsoft.com/zh-CN/download/details.aspx?id=48145)。
diff --git a/install/mindspore_cpu_win_install_en.md b/install/mindspore_cpu_win_install_en.md
index 300d0b2738608606e9f520d0ab240c8689e26bd0..8cb5a193a5be510ec5e0a389b9523c7960e70131 100644
--- a/install/mindspore_cpu_win_install_en.md
+++ b/install/mindspore_cpu_win_install_en.md
@@ -22,7 +22,7 @@ This document describes how to quickly install MindSpore on a Windows system wit
| ---- | :--- | :--- | :--- |
| MindSpore master | Windows 10 x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5
- For details about other dependency items, see [requirements.txt](https://gitee.com/mindspore/mindspore/blob/master/requirements.txt). | **Compilation dependencies:**
- [Python](https://www.python.org/downloads/) 3.7.5
- [MinGW-W64 GCC-7.3.0](https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/7.3.0/threads-posix/seh/x86_64-7.3.0-release-posix-seh-rt_v5-rev0.7z) x86_64-posix-seh
- [ActivePerl](http://downloads.activestate.com/ActivePerl/releases/5.24.3.2404/ActivePerl-5.24.3.2404-MSWin32-x64-404865.exe) 5.24.3.2404
- [CMake](https://cmake.org/download/) 3.14.1
- [wheel](https://pypi.org/project/wheel/) >= 0.32.0
**Installation dependencies:**
same as the executable file installation dependencies. |
-- When the network is connected, dependency items in the requirements.txt file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
+- When the network is connected, dependency items in the `requirements.txt` file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
### (Optional) Installing Conda
@@ -72,7 +72,7 @@ This document describes how to quickly install MindSpore on a Windows system wit
```
> - Before running the preceding command, ensure that the paths of mingw64\bin\ and the executable files cmake have been added to the environment variable PATH.
> - If git was not installed in `ProgramFiles`, you will need to set environment variable to where `patch.exe` is allocated. For example, when git was install in `D:\git`, `set MS_PATCH_PATH=D:\git\usr\bin`.
- > - In the build.bat script, the git clone command will be executed to obtain the code in the third-party dependency database. Ensure that the network settings of Git are correct.
+ > - In the `build.bat` script, the git clone command will be executed to obtain the code in the third-party dependency database. Ensure that the network settings of Git are correct.
> - If the compiler performance is strong, you can add -j{Number of threads} in to script to increase the number of threads(Default 6). For example, `call build.bat 12`.
> - Before running the preceding command, ensure that [Visual C ++ Redistributable for Visual Studio 2015](https://www.microsoft.com/zh-CN/download/details.aspx?id=48145) is installed.
diff --git a/install/mindspore_d_install_en.md b/install/mindspore_d_install_en.md
index 9ecfce87e3e987141845b6169c392dbc9f8ce1a5..597b029273f8e6eb289aeeaaa185a83042f88024 100644
--- a/install/mindspore_d_install_en.md
+++ b/install/mindspore_d_install_en.md
@@ -36,7 +36,7 @@ This document describes how to quickly install MindSpore on an Ascend AI process
- Confirm that the current user has the right to access the installation path `/usr/local/Ascend `of Ascend 910 AI processor software package(Version:Atlas Data Center Solution V100R020C00T100). If not, the root user needs to add the current user to the user group where `/usr/local/Ascend` is located. For the specific configuration, please refer to the software package instruction document.
- When Ubuntu version is 18.04, GCC 7.3.0 can be installed by using apt command.
-- When the network is connected, dependency items in the requirements.txt file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
+- When the network is connected, dependency items in the `requirements.txt` file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
### (Optional) Installing Conda
@@ -90,8 +90,8 @@ The compilation and installation must be performed on the Ascend 910 AI processo
bash build.sh -e d -z
```
> - Before running the preceding command, ensure that the paths where the executable files cmake and patch store have been added to the environment variable PATH.
- > - In the build.sh script, the git clone command will be executed to obtain the code in the third-party dependency database. Ensure that the network settings of Git are correct.
- > - In the build.sh script, the default number of compilation threads is 8. If the compiler performance is poor, compilation errors may occur. You can add -j{Number of threads} in to script to reduce the number of threads. For example, `bash build.sh -e d -z -j4`.
+ > - In the `build.sh` script, the git clone command will be executed to obtain the code in the third-party dependency database. Ensure that the network settings of Git are correct.
+ > - In the `build.sh` script, the default number of compilation threads is 8. If the compiler performance is poor, compilation errors may occur. You can add -j{Number of threads} in to script to reduce the number of threads. For example, `bash build.sh -e d -z -j4`.
3. Run the following command to install MindSpore:
@@ -161,7 +161,7 @@ If you need to analyze information such as model scalars, graphs, and model trac
| ---- | :--- | :--- | :--- |
| MindInsight master | - Ubuntu 16.04 or later aarch64
- Ubuntu 16.04 or later x86_64
- EulerOS 2.8 aarch64
- EulerOS 2.5 x86_64
| - [Python](https://www.python.org/downloads/) 3.7.5
- MindSpore master
- For details about other dependency items, see [requirements.txt](https://gitee.com/mindspore/mindinsight/blob/master/requirements.txt). | **Compilation dependencies:**
- [Python](https://www.python.org/downloads/) 3.7.5
- [CMake](https://cmake.org/download/) >= 3.14.1
- [GCC](https://gcc.gnu.org/releases.html) 7.3.0
- [node.js](https://nodejs.org/en/download/) >= 10.19.0
- [wheel](https://pypi.org/project/wheel/) >= 0.32.0
- [pybind11](https://pypi.org/project/pybind11/) >= 2.4.3
**Installation dependencies:**
same as the executable file installation dependencies. |
-- When the network is connected, dependency items in the requirements.txt file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
+- When the network is connected, dependency items in the `requirements.txt` file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
## Installation Guide
@@ -228,7 +228,7 @@ If you need to conduct AI model security research or enhance the security of the
| ---- | :--- | :--- | :--- |
| MindArmour master | - Ubuntu 16.04 or later aarch64
- Ubuntu 16.04 or later x86_64
- EulerOS 2.8 aarch64
- EulerOS 2.5 x86_64
| - [Python](https://www.python.org/downloads/) 3.7.5
- MindSpore master
- For details about other dependency items, see [setup.py](https://gitee.com/mindspore/mindarmour/blob/master/setup.py). | Same as the executable file installation dependencies. |
-- When the network is connected, dependency items in the setup.py file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
+- When the network is connected, dependency items in the `setup.py` file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
## Installation Guide
diff --git a/install/mindspore_gpu_install.md b/install/mindspore_gpu_install.md
index 537b32933aced82e98e0debc2a5239e3a2922af0..a0c30cccea8bcda4d021e7c3a678c6d67f875329 100644
--- a/install/mindspore_gpu_install.md
+++ b/install/mindspore_gpu_install.md
@@ -31,7 +31,7 @@
| MindSpore master | Ubuntu 16.04(及以上) x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5
- [CUDA 9.2](https://developer.nvidia.com/cuda-92-download-archive) / [CUDA 10.1](https://developer.nvidia.com/cuda-10.1-download-archive-base)
- [CuDNN](https://developer.nvidia.com/rdp/cudnn-archive) >= 7.6
- [OpenMPI](https://www.open-mpi.org/faq/?category=building#easy-build) 3.1.5 (可选,单机多卡/多机多卡训练需要)
- [NCCL](https://docs.nvidia.com/deeplearning/sdk/nccl-install-guide/index.html#debian) 2.4.8-1 (可选,单机多卡/多机多卡训练需要)
- 其他依赖项参见[requirements.txt](https://gitee.com/mindspore/mindspore/blob/master/requirements.txt) | **编译依赖:**
- [Python](https://www.python.org/downloads/) 3.7.5
- [wheel](https://pypi.org/project/wheel/) >= 0.32.0
- [CMake](https://cmake.org/download/) >= 3.14.1
- [GCC](https://gcc.gnu.org/releases.html) 7.3.0
- [patch](http://ftp.gnu.org/gnu/patch/) >= 2.5
- [Autoconf](https://www.gnu.org/software/autoconf) >= 2.69
- [Libtool](https://www.gnu.org/software/libtool) >= 2.4.6-29.fc30
- [Automake](https://www.gnu.org/software/automake) >= 1.15.1
- [CUDA 9.2](https://developer.nvidia.com/cuda-92-download-archive) / [CUDA 10.1](https://developer.nvidia.com/cuda-10.1-download-archive-base)
- [CuDNN](https://developer.nvidia.com/rdp/cudnn-archive) >= 7.6
**安装依赖:**
与可执行文件安装依赖相同 |
- Ubuntu版本为18.04时,GCC 7.3.0可以直接通过apt命令安装。
-- 在联网状态下,安装whl包时会自动下载requirements.txt中的依赖项,其余情况需自行安装。
+- 在联网状态下,安装whl包时会自动下载`requirements.txt`中的依赖项,其余情况需自行安装。
- 为了方便用户使用,MindSpore降低了对Autoconf、Libtool、Automake版本的依赖,可以使用系统自带版本。
### Conda安装(可选)
@@ -72,8 +72,8 @@
bash build.sh -e gpu -M on -z
```
> - 在执行上述命令前,需保证可执行文件cmake和patch所在路径已加入环境变量PATH中。
- > - build.sh中会执行git clone获取第三方依赖库的代码,请提前确保git的网络设置正确可用。
- > - build.sh中默认的编译线程数为8,如果编译机性能较差可能会出现编译错误,可在执行中增加-j{线程数}来减少线程数量。如`bash build.sh -e gpu -M on -z -j4`。
+ > - `build.sh`中会执行git clone获取第三方依赖库的代码,请提前确保git的网络设置正确可用。
+ > - `build.sh`中默认的编译线程数为8,如果编译机性能较差可能会出现编译错误,可在执行中增加-j{线程数}来减少线程数量。如`bash build.sh -e gpu -M on -z -j4`。
3. 执行如下命令安装MindSpore。
@@ -126,7 +126,7 @@
| ---- | :--- | :--- | :--- |
| MindInsight master | - Ubuntu 16.04(及以上) x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5
- MindSpore master
- 其他依赖项参见[requirements.txt](https://gitee.com/mindspore/mindinsight/blob/master/requirements.txt) | **编译依赖:**
- [Python](https://www.python.org/downloads/) 3.7.5
- [CMake](https://cmake.org/download/) >= 3.14.1
- [GCC](https://gcc.gnu.org/releases.html) 7.3.0
- [node.js](https://nodejs.org/en/download/) >= 10.19.0
- [wheel](https://pypi.org/project/wheel/) >= 0.32.0
- [pybind11](https://pypi.org/project/pybind11/) >= 2.4.3
**安装依赖:**
与可执行文件安装依赖相同 |
-- 在联网状态下,安装whl包时会自动下载requirements.txt中的依赖项,其余情况需自行安装。
+- 在联网状态下,安装whl包时会自动下载`requirements.txt`中的依赖项,其余情况需自行安装。
## 安装指南
@@ -165,7 +165,7 @@
(2) 构建whl包进行安装。
- 进入源码的根目录,先执行build目录下的MindInsight编译脚本,再执行命令安装output目录下生成的whl包。
+ 进入源码的根目录,先执行`build`目录下的MindInsight编译脚本,再执行命令安装output目录下生成的whl包。
```bash
cd mindinsight
@@ -191,7 +191,7 @@
| ---------------------- | :------------------ | :----------------------------------------------------------- | :----------------------- |
| MindArmour master | Ubuntu 16.04(及以上) x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5
- MindSpore master
- 其他依赖项参见[setup.py](https://gitee.com/mindspore/mindarmour/blob/master/setup.py) | 与可执行文件安装依赖相同 |
-- 在联网状态下,安装whl包时会自动下载setup.py中的依赖项,其余情况需自行安装。
+- 在联网状态下,安装whl包时会自动下载`setup.py`中的依赖项,其余情况需自行安装。
## 安装指南
diff --git a/install/mindspore_gpu_install_en.md b/install/mindspore_gpu_install_en.md
index 4c41f09d87c8ad1f8cc16651314a7fbf4bb3dd4a..94e88cf95a1ef03e241b34b85b31569aaacf09ac 100644
--- a/install/mindspore_gpu_install_en.md
+++ b/install/mindspore_gpu_install_en.md
@@ -31,7 +31,7 @@ This document describes how to quickly install MindSpore on a NVIDIA GPU environ
| MindSpore master | Ubuntu 16.04 or later x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5
- [CUDA 9.2](https://developer.nvidia.com/cuda-92-download-archive) / [CUDA 10.1](https://developer.nvidia.com/cuda-10.1-download-archive-base)
- [CuDNN](https://developer.nvidia.com/rdp/cudnn-archive) >= 7.6
- [OpenMPI](https://www.open-mpi.org/faq/?category=building#easy-build) 3.1.5 (optional, required for single-node/multi-GPU and multi-node/multi-GPU training)
- [NCCL](https://docs.nvidia.com/deeplearning/sdk/nccl-install-guide/index.html#debian) 2.4.8-1 (optional, required for single-node/multi-GPU and multi-node/multi-GPU training)
- For details about other dependency items, see [requirements.txt](https://gitee.com/mindspore/mindspore/blob/master/requirements.txt). | **Compilation dependencies:**
- [Python](https://www.python.org/downloads/) 3.7.5
- [wheel](https://pypi.org/project/wheel/) >= 0.32.0
- [CMake](https://cmake.org/download/) >= 3.14.1
- [GCC](https://gcc.gnu.org/releases.html) 7.3.0
- [patch](http://ftp.gnu.org/gnu/patch/) >= 2.5
- [Autoconf](https://www.gnu.org/software/autoconf) >= 2.69
- [Libtool](https://www.gnu.org/software/libtool) >= 2.4.6-29.fc30
- [Automake](https://www.gnu.org/software/automake) >= 1.15.1
- [CUDA 9.2](https://developer.nvidia.com/cuda-92-download-archive) / [CUDA 10.1](https://developer.nvidia.com/cuda-10.1-download-archive-base)
- [CuDNN](https://developer.nvidia.com/rdp/cudnn-archive) >= 7.6
**Installation dependencies:**
same as the executable file installation dependencies. |
- When Ubuntu version is 18.04, GCC 7.3.0 can be installed by using apt command.
-- When the network is connected, dependency items in the requirements.txt file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
+- When the network is connected, dependency items in the `requirements.txt` file are automatically downloaded during `.whl` package installation. In other cases, you need to manually install dependency items.
- MindSpore reduces dependency on Autoconf, Libtool, Automake versions for the convenience of users, default versions of these tools built in their systems are now supported.
### (Optional) Installing Conda
@@ -72,8 +72,8 @@ This document describes how to quickly install MindSpore on a NVIDIA GPU environ
bash build.sh -e gpu -M on -z
```
> - Before running the preceding command, ensure that the paths where the executable files cmake and patch store have been added to the environment variable PATH.
- > - In the build.sh script, the git clone command will be executed to obtain the code in the third-party dependency database. Ensure that the network settings of Git are correct.
- > - In the build.sh script, the default number of compilation threads is 8. If the compiler performance is poor, compilation errors may occur. You can add -j{Number of threads} in to script to reduce the number of threads. For example, `bash build.sh -e gpu -M on -z -j4`.
+ > - In the `build.sh` script, the git clone command will be executed to obtain the code in the third-party dependency database. Ensure that the network settings of Git are correct.
+ > - In the `build.sh` script, the default number of compilation threads is 8. If the compiler performance is poor, compilation errors may occur. You can add -j{Number of threads} in to script to reduce the number of threads. For example, `bash build.sh -e gpu -M on -z -j4`.
3. Run the following command to install MindSpore:
@@ -126,7 +126,7 @@ If you need to analyze information such as model scalars, graphs, and model trac
| ---- | :--- | :--- | :--- |
| MindInsight master | - Ubuntu 16.04 or later x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5
- MindSpore master
- For details about other dependency items, see [requirements.txt](https://gitee.com/mindspore/mindinsight/blob/master/requirements.txt). | **Compilation dependencies:**
- [Python](https://www.python.org/downloads/) 3.7.5
- [CMake](https://cmake.org/download/) >= 3.14.1
- [GCC](https://gcc.gnu.org/releases.html) 7.3.0
- [node.js](https://nodejs.org/en/download/) >= 10.19.0
- [wheel](https://pypi.org/project/wheel/) >= 0.32.0
- [pybind11](https://pypi.org/project/pybind11/) >= 2.4.3
**Installation dependencies:**
same as the executable file installation dependencies. |
-- When the network is connected, dependency items in the requirements.txt file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
+- When the network is connected, dependency items in the `requirements.txt` file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
## Installation Guide
@@ -193,7 +193,7 @@ If you need to conduct AI model security research or enhance the security of the
| ---- | :--- | :--- | :--- |
| MindArmour master | Ubuntu 16.04 or later x86_64 | - [Python](https://www.python.org/downloads/) 3.7.5
- MindSpore master
- For details about other dependency items, see [setup.py](https://gitee.com/mindspore/mindarmour/blob/master/setup.py). | Same as the executable file installation dependencies. |
-- When the network is connected, dependency items in the setup.py file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
+- When the network is connected, dependency items in the `setup.py` file are automatically downloaded during .whl package installation. In other cases, you need to manually install dependency items.
## Installation Guide
diff --git a/tutorials/source_en/advanced_use/checkpoint_for_hybrid_parallel.md b/tutorials/source_en/advanced_use/checkpoint_for_hybrid_parallel.md
index fb87d25a9488ef410af2ec8d61a6d783082365a0..7a59e00dd4dcfb31413c9e93bcf5a8b4904fa746 100644
--- a/tutorials/source_en/advanced_use/checkpoint_for_hybrid_parallel.md
+++ b/tutorials/source_en/advanced_use/checkpoint_for_hybrid_parallel.md
@@ -95,8 +95,8 @@ load_param_into_net(net, param_dict)
In the preceding information:
-- `load_checkpoint()`: loads the checkpoint model parameter file and returns a parameter dictionary.
-- `load_param_into_net()`: loads model parameter data to the network.
+- `load_checkpoint`: loads the checkpoint model parameter file and returns a parameter dictionary.
+- `load_param_into_net`: loads model parameter data to the network.
- `CKP_1-4_32.ckpt`: name of the saved checkpoint model parameter file.
> If a new checkpoint file is directly saved in the training environment based on the current training data and the parameter values already exist on the network, skip this step and you do not need to import the checkpoint files.
@@ -238,7 +238,7 @@ Call the `load_checkpoint` API to load model parameter data from the checkpoint
param_dict = load_checkpoint("./CKP-Integrated_1-4_32.ckpt")
```
-- `load_checkpoint()`: loads the checkpoint model parameter file and returns a parameter dictionary.
+- `load_checkpoint`: loads the checkpoint model parameter file and returns a parameter dictionary.
- `CKP-Integrated_1-4_32.ckpt`: name of the checkpoint model parameter file to be loaded.
### Step 2: Dividing a Model Parallel Parameter
@@ -422,7 +422,7 @@ User process:
- `mode=context.GRAPH_MODE`: sets the running mode to graph mode for distributed training. (The PyNative mode does not support parallel running.)
- `device_id`: physical sequence number of a device, that is, the actual sequence number of the device on a computer where the device is located.
- - `init()`: completes the distributed training initialization.
+ - `init`: completes the distributed training initialization.
The command output is as follows.
diff --git a/tutorials/source_en/advanced_use/customized_debugging_information.md b/tutorials/source_en/advanced_use/customized_debugging_information.md
index 1d9b2df80d788f88215b93643503234242c83911..008185605e6b628735a51d030f0c9dfe756f5f97 100644
--- a/tutorials/source_en/advanced_use/customized_debugging_information.md
+++ b/tutorials/source_en/advanced_use/customized_debugging_information.md
@@ -18,7 +18,7 @@
## Overview
-This section describes how to use the customized capabilities provided by MindSpore, such as callback, metrics, and log printing, to help you quickly debug the training network.
+This section describes how to use the customized capabilities provided by MindSpore, such as `callback`, `metrics`, and `log printing`, to help you quickly debug the training network.
## Introduction to Callback
@@ -29,7 +29,7 @@ For example, you can monitor the loss, save model parameters, dynamically adjust
MindSpore provides the callback capabilities to allow users to insert customized operations in a specific phase of training or inference, including:
-- Callback functions such as ModelCheckpoint, LossMonitor, and SummaryStep provided by the MindSpore framework
+- `Callback` functions such as `ModelCheckpoint`, `LossMonitor`, and `SummaryStep` provided by the MindSpore framework
- Custom callback functions
Usage: Transfer the callback object in the model.train method. The callback object can be a list, for example:
@@ -127,8 +127,8 @@ The output is as follows:
epoch: 20 step: 32 loss: 2.298344373703003
```
-This callback function is used to terminate the training within a specified period. You can use the `run_context.original_args()` method to obtain the `cb_params` dictionary, which contains the main attribute information described above.
-In addition, you can modify and add values in the dictionary. In the preceding example, an `init_time` object is defined in `begin()` and transferred to the `cb_params` dictionary.
+This callback function is used to terminate the training within a specified period. You can use the `run_context.original_args` method to obtain the `cb_params` dictionary, which contains the main attribute information described above.
+In addition, you can modify and add values in the dictionary. In the preceding example, an `init_time` object is defined in `begin` and transferred to the `cb_params` dictionary.
A decision is made at each `step_end`. When the training time is greater than the configured time threshold, a training termination signal will be sent to the `run_context` to terminate the training in advance and the current values of epoch, step, and loss will be printed.
## MindSpore Metrics
@@ -155,16 +155,16 @@ ds_eval = create_dataset()
output = model.eval(ds_eval)
```
-The `model.eval()` method returns a dictionary that contains the metrics and results transferred to the metrics.
+The `model.eval` method returns a dictionary that contains the metrics and results transferred to the metrics.
You can also define your own metrics class by inheriting the `Metric` base class and rewriting the `clear`, `update`, and `eval` methods.
The `accuracy` operator is used as an example to describe the internal implementation principle.
The `accuracy` inherits the `EvaluationBase` base class and rewrites the preceding three methods.
-The `clear()` method initializes related calculation parameters in the class.
-The `update()` method accepts the predicted value and tag value and updates the internal variables of accuracy.
-The `eval()` method calculates related indicators and returns the calculation result.
+The `clear` method initializes related calculation parameters in the class.
+The `update` method accepts the predicted value and tag value and updates the internal variables of accuracy.
+The `eval` method calculates related indicators and returns the calculation result.
By invoking the `eval` method of `accuracy`, you will obtain the calculation result.
You can understand how `accuracy` runs by using the following code:
@@ -185,7 +185,7 @@ Accuracy is 0.6667
```
## MindSpore Print Operator
MindSpore-developed print operator is used to print the tensors or character strings input by users. Multiple strings, multiple tensors, and a combination of tensors and strings are supported, which are separated by comma (,).
-The use method of MindSpore print operator is the same that of other operators. You need to assert MindSpore print operator in `__init__`() and invoke using `construct()`. The following is an example.
+The use method of MindSpore print operator is the same that of other operators. You need to assert MindSpore print operator in `__init__` and invoke using `construct`. The following is an example.
```python
import numpy as np
from mindspore import Tensor
@@ -226,11 +226,9 @@ MindSpore uses glog to output logs. The following environment variables are comm
1. GLOG_v specifies the log level. The default value is 2, indicating the WARNING level. The values are as follows: 0: DEBUG; 1: INFO; 2: WARNING; 3: ERROR.
2. When GLOG_logtostderr is set to 1, logs are output to the screen. If the value is set to 0, logs are output to a file. Default value: 1
-3. GLOG_log_dir=YourPath specifies the log output path. If GLOG_logtostderr is set to 0, value of this variable must be specified. If GLOG_log_dir is specified and the value of GLOG_logtostderr is 1, logs are output to the screen but not to a file. Logs of C++ and Python will be output to different files. The file name of C++ log complies with the naming rule of GLOG log file. Here, the name is `mindspore.MachineName.UserName.log.LogLevel.Timestamp`. The file name of Python log is `mindspore.log`.
+3. GLOG_log_dir=*YourPath* specifies the log output path. If GLOG_logtostderr is set to 0, value of this variable must be specified. If GLOG_log_dir is specified and the value of GLOG_logtostderr is 1, logs are output to the screen but not to a file. Logs of C++ and Python will be output to different files. The file name of C++ log complies with the naming rule of GLOG log file. Here, the name is `mindspore.MachineName.UserName.log.LogLevel.Timestamp`. The file name of Python log is `mindspore.log`.
4. MS_SUBMODULE_LOG_v="{SubModule1:LogLevel1,SubModule2:LogLevel2,...}" specifies log levels of C++ sub modules of MindSpore. The specified sub module log level will overwrite the global log level. The meaning of submodule log level is same as GLOG_v, the sub modules of MindSpore grouped by source directory is as the bellow table. E.g. when set `GLOG_v=1 MS_SUBMODULE_LOG_v="{PARSER:2,ANALYZER:2}"` then log levels of `PARSER` and `ANALYZER` are WARNING, other modules' log levels are INFO.
-> The glog does not support to rotate the log files. If you need to control the disk space usage for log files, you can use the log file management tools provided by the operating system, such as Linux logrotate.
-
Sub moudles of MindSpore grouped by source directory:
| Source Files | Sub Module Name |
diff --git a/tutorials/source_en/advanced_use/distributed_training.md b/tutorials/source_en/advanced_use/distributed_training.md
index 08a975a31199c6d6268301ecd6aabbc820f269fc..9c088830a5fa0c9cd45e275e6bbdf69039f5e1a2 100644
--- a/tutorials/source_en/advanced_use/distributed_training.md
+++ b/tutorials/source_en/advanced_use/distributed_training.md
@@ -1,56 +1,46 @@
-# Getting Started with Parallel Distributed Training
+# Getting Started with Distributed Training
-- [Getting Started with Parallel Distributed Training](#getting-started-with-parallel-distributed-training)
+- [Getting Started with Distributed Training](#getting-started-with-distributed-training)
- [Overview](#overview)
- [Preparations](#preparations)
- - [Downloading the Dataset](#downloading-the-dataset)
- [Configuring Distributed Environment Variables](#configuring-distributed-environment-variables)
- - [Calling the Collective Communication Library](#calling-the-collective-communication-library)
- - [Loading the Dataset in Data Parallel Mode](#loading-the-dataset-in-data-parallel-mode)
+ - [Invoking the Collective Communication Library](#invoking-the-collective-communication-library)
+ - [Loading Datasets](#loading-datasets)
- [Defining the Network](#defining-the-network)
- [Defining the Loss Function and Optimizer](#defining-the-loss-function-and-optimizer)
- [Defining the Loss Function](#defining-the-loss-function)
- [Defining the Optimizer](#defining-the-optimizer)
- [Training the Network](#training-the-network)
- - [Running the Script](#running-the-script)
+ - [Running Test Cases](#running-test-cases)
## Overview
-In deep learning, the increasing number of datasets and parameters prolongs the training time and requires more hardware resources, becoming a training bottleneck. Parallel distributed training is an important optimization method for training, which can reduce requirements on hardware, such as memory and computing performance. Based on different parallel principles and modes, parallelism is generally classified into the following types:
-- Data parallelism: splits data into many batches and then allocates the batches to each worker for model computation.
-- Model parallelism: splits a model. MindSpore supports the intra-layer model parallelism. Parameters are split and then allocated to each worker for training.
-- Hybrid parallelism: contains data parallelism and model parallelism.
+MindSpore supports `DATA_PARALLEL` and `AUTO_PARALLEL`. Automatic parallel is a distributed parallel mode that integrates data parallel, model parallel, and hybrid parallel. It can automatically establish cost models and select a parallel mode for users.
-MindSpore also provides the parallel distributed training function. It supports the following modes:
-- `DATA_PARALLEL`: data parallelism.
-- `AUTO_PARALLEL`: automatic parallelism, which integrates data parallelism, model parallelism, and hybrid parallelism. A cost model can be automatically created to select one parallel mode for users. Creating a cost model refers to modeling the training time based on the memory-based computation and communication overheads of the Ascend 910 chip, and designing efficient algorithms to develop a parallel strategy with a relatively short training time.
-- `HYBRID_PARALLEL`: On MindSpore, users manually split parameters to implement intra-layer model parallelism.
+Among them:
+- Data parallel: A parallel mode for dividing data in batches.
+- Layerwise parallel: A parallel mode for dividing parameters by channel.
+- Hybrid parallel: A parallel mode that covers both data parallel and model parallel.
+- Cost model: A cost model built based on the memory computing cost and communication cost, for which an efficient algorithm is designed to find the parallel strategy with the shorter training time.
-This tutorial describes how to train the ResNet-50 network in data parallel and automatic parallel modes on MindSpore.
-> The example in this tutorial applies to hardware platforms based on the Ascend 910 AI processor, whereas does not support CPU and GPU scenarios.
-> Download address of the complete sample code:
+In this tutorial, we will learn how to train the ResNet-50 network in `DATA_PARALLEL` or `AUTO_PARALLEL` mode on MindSpore.
-## Preparations
-
-### Downloading the Dataset
-
-This sample uses the `CIFAR-10` dataset, which consists of color images of 32 x 32 pixels in 10 classes, with 6000 images per class. There are 50,000 images in the training set and 10,000 images in the test set.
+> The current sample is for the Ascend 910 AI processor. CPU and GPU processors are not supported for now.
+> You can find the complete executable sample code at:.
-> `CIFAR-10` dataset download address:
-
-Download the dataset and decompress it to a local path. The folder generated after the decompression is `cifar-10-batches-bin`.
+## Preparations
### Configuring Distributed Environment Variables
-When distributed training is performed in the bare-metal environment (compared with the cloud environment where the Ascend 910 AI processor is deployed on the local host), you need to configure the networking information file for the current multi-device environment. If the HUAWEI CLOUD environment is used, skip this section because the cloud service has been configured.
+When distributed training is performed in the lab environment, you need to configure the networking information file for the current multi-card environment. If HUAWEI CLOUD is used, skip this section.
-The following uses the Ascend 910 AI processor as an example. The JSON configuration file for an environment with eight devices is as follows. In this example, the configuration file is named `rank_table_8pcs.json`. For details about how to configure the 2-device environment, see the `rank_table_2pcs.json` file in the sample code.
+The Ascend 910 AI processor and AIServer are used as an example. The JSON configuration file of a two-card environment is as follows. In this example, the configuration file is named rank_table.json.
```json
{
@@ -60,50 +50,45 @@ The following uses the Ascend 910 AI processor as an example. The JSON configura
"group_count": "1",
"group_list": [
{
- "device_num": "8",
+ "device_num": "2",
"server_num": "1",
"group_name": "",
- "instance_count": "8",
+ "instance_count": "2",
"instance_list": [
- {"devices": [{"device_id": "0","device_ip": "192.1.27.6"}],"rank_id": "0","server_id": "10.155.111.140"},
- {"devices": [{"device_id": "1","device_ip": "192.2.27.6"}],"rank_id": "1","server_id": "10.155.111.140"},
- {"devices": [{"device_id": "2","device_ip": "192.3.27.6"}],"rank_id": "2","server_id": "10.155.111.140"},
- {"devices": [{"device_id": "3","device_ip": "192.4.27.6"}],"rank_id": "3","server_id": "10.155.111.140"},
- {"devices": [{"device_id": "4","device_ip": "192.1.27.7"}],"rank_id": "4","server_id": "10.155.111.140"},
- {"devices": [{"device_id": "5","device_ip": "192.2.27.7"}],"rank_id": "5","server_id": "10.155.111.140"},
- {"devices": [{"device_id": "6","device_ip": "192.3.27.7"}],"rank_id": "6","server_id": "10.155.111.140"},
- {"devices": [{"device_id": "7","device_ip": "192.4.27.7"}],"rank_id": "7","server_id": "10.155.111.140"}
- ]
+ {"devices":[{"device_id":"0","device_ip":"192.1.27.6"}],"rank_id":"0","server_id":"10.155.111.140"},
+ {"devices":[{"device_id":"1","device_ip":"192.2.27.6"}],"rank_id":"1","server_id":"10.155.111.140"}
+ ]
}
],
"para_plane_nic_location": "device",
- "para_plane_nic_name": ["eth0","eth1","eth2","eth3","eth4","eth5","eth6","eth7"],
- "para_plane_nic_num": "8",
+ "para_plane_nic_name": [
+ "eth0", "eth1"
+ ],
+ "para_plane_nic_num": "2",
"status": "completed"
}
```
The following parameters need to be modified based on the actual training environment:
+1. `board_id` indicates the environment in which the program runs.
+2. `server_num` indicates the number of hosts, and `server_id` indicates the IP address of the local host.
+3. `device_num`, `para_plane_nic_num`, and `instance_count` indicate the number of cards.
+4. `rank_id` indicates the logical sequence number of a card, which starts from 0 fixedly. `device_id` indicates the physical sequence number of a card, that is, the actual sequence number of the host where the card is located.
+5. `device_ip` indicates the IP address of the NIC. You can run the `cat /etc/hccn.conf` command on the current host to obtain the IP address of the NIC.
+6. `para_plane_nic_name` indicates the name of the corresponding NIC.
-- `board_id`: current running environment. Set this parameter to `0x0000` for x86, and to `0x0020` for ARM.
-- `server_num`: number of hosts.
-- `server_id`: IP address of the local host.
-- `device_num`, `para_plane_nic_num`, and `instance_count`: number of devices.
-- `rank_id`: logical sequence number of a device, which starts from 0.
-- `device_id`: physical sequence number of a device, that is, the actual sequence number of the device on the corresponding host.
-- `device_ip`: IP address of the integrated NIC. You can run the `cat /etc/hccn.conf` command on the current host. The key value of `address_x` is the IP address of the NIC.
-- `para_plane_nic_name`: name of the corresponding NIC.
+After the networking information file is ready, add the file path to the environment variable `MINDSPORE_HCCL_CONFIG_PATH`. In addition, the `device_id` information needs to be transferred to the script. In this example, the information is transferred by configuring the environment variable DEVICE_ID.
+```bash
+export MINDSPORE_HCCL_CONFIG_PATH="./rank_table.json"
+export DEVICE_ID=0
+```
-### Calling the Collective Communication Library
+### Invoking the Collective Communication Library
-The Huawei Collective Communication Library (HCCL) is used for the communication of MindSpore parallel distributed training and can be found in the Ascend 310 AI processor software package. In addition, `mindspore.communication.management` encapsulates the collective communication API provided by the HCCL to help users configure distributed information.
-> HCCL implements multi-device multi-node communication based on the Ascend AI processor. The common restrictions on using the distributed service are as follows. For details, see the HCCL documentation.
-> - In a single-node system, a cluster of 1, 2, 4, or 8 devices is supported. In a multi-node system, a cluster of 8 x N devices is supported.
-> - Each host has four devices numbered 0 to 3 and four devices numbered 4 to 7 deployed on two different networks. During training of 2 or 4 devices, the devices must be connected and clusters cannot be created across networks.
-> - The server hardware architecture and operating system require the symmetrical multi-processing (SMP) mode.
+You need to set the `device_id` parameter, and invoke `init` to complete the initialization operation.
-The sample code for calling the HCCL as follows:
+In the sample, the graph mode is used during runtime. On the Ascend AI processor, Huawei Collective Communication Library (HCCL) is used.
```python
import os
@@ -116,15 +101,16 @@ if __name__ == "__main__":
...
```
-In the preceding code:
-- `mode=context.GRAPH_MODE`: sets the running mode to graph mode for distributed training. (The PyNative mode does not support parallel running.)
-- `device_id`: physical sequence number of a device, that is, the actual sequence number of the device on the corresponding host.
-- `init()`: enables HCCL communication and completes the distributed training initialization.
+`mindspore.communication.management` encapsulates the collective communication API provided by the HCCL to help users obtain distributed information. The common types include `get_rank` and `get_group_size`, which correspond to the ID of the current card in the cluster and the number of cards, respectively.
+> HCCL implements multi-device multi-card communication based on the Da Vinci architecture chip. The restrictions on using the distributed service are as follows:
+> 1. In a single-node system, a cluster of 1, 2, 4, or 8 cards is supported. In a multi-node system, a cluster of 8 x N cards is supported.
+> 2. Each server has four NICs (numbered 0 to 3) and four NICs (numbered 4 to 7) deployed on two different networks. During training of two or four cards, the NICs must be connected and clusters cannot be created across networks.
+> 3. The operating system needs to use the symmetric multiprocessing (SMP) mode.
-## Loading the Dataset in Data Parallel Mode
-
-During distributed training, data is imported in data parallel mode. The following takes the CIFAR-10 dataset as an example to describe how to import the CIFAR-10 dataset in data parallel mode. `data_path` indicates the dataset path, which is also the path of the `cifar-10-batches-bin` folder.
+## Loading Datasets
+During distributed training, data is imported in data parallel mode. The following uses Cifar10Dataset as an example to describe how to import the CIFAR-10 dataset in parallel mode, `data_path` is the path of the dataset.
+Different from a single-node system, the multi-node system needs to transfer `num_shards` and `shard_id` parameters to the dataset API, which correspond to the number of cards and logical sequence number of the NIC, respectively. You are advised to obtain the parameters through the HCCL API.
```python
import mindspore.common.dtype as mstype
@@ -133,7 +119,7 @@ import mindspore.dataset.transforms.c_transforms as C
import mindspore.dataset.transforms.vision.c_transforms as vision
from mindspore.communication.management import get_rank, get_group_size
-def create_dataset(data_path, repeat_num=1, batch_size=32, rank_id=0, rank_size=1):
+def create_dataset(repeat_num=1, batch_size=32, rank_id=0, rank_size=1):
resize_height = 224
resize_width = 224
rescale = 1.0 / 255.0
@@ -171,21 +157,19 @@ def create_dataset(data_path, repeat_num=1, batch_size=32, rank_id=0, rank_size=
return data_set
```
-Different from the single-node system, the multi-node system needs to transfer the `num_shards` and `shard_id` parameters to the dataset API. The two parameters correspond to the number of devices and logical sequence numbers of devices, respectively. You are advised to obtain the parameters through the HCCL API.
-- `get_rank`: obtains the ID of the current device in the cluster.
-- `get_group_size`: obtains the number of devices.
## Defining the Network
-In data parallel and automatic parallel modes, the network definition method is the same as that in a single-node system. The reference code is as follows:
+In `DATA_PARALLEL` and `AUTO_PARALLEL` modes, the network definition mode is the same as that of a single-node system. For sample code, see at
+
+ .
## Defining the Loss Function and Optimizer
### Defining the Loss Function
-Automatic parallelism splits models using the operator granularity and obtains the optimal parallel strategy through algorithm search. Therefore, to achieve a better parallel training effect, you are advised to use small operators to implement the loss function.
-
-In the Loss function, the `SoftmaxCrossEntropyWithLogits` is expanded into multiple small operators for implementation according to a mathematical formula. The sample code is as follows:
+In the Loss function, the SoftmaxCrossEntropyWithLogits is expanded into multiple small operators for implementation according to a mathematical formula.
+Compared with fusion loss, the loss in `AUTO_PARALLEL` mode searches and finds optimal parallel strategy by operator according to an algorithm.
```python
from mindspore.ops import operations as P
@@ -229,129 +213,64 @@ class SoftmaxCrossEntropyExpand(nn.Cell):
### Defining the Optimizer
-The `Momentum` optimizer is used as the parameter update tool. The definition is the same as that in the single-node system. For details, see the implementation in the sample code.
+The `Momentum` optimizer is used as the parameter update tool. The definition is the same as that of a single-node system.
-## Training the Network
+```python
+from mindspore.nn.optim.momentum import Momentum
+lr = 0.01
+momentum = 0.9
+opt = Momentum(filter(lambda x: x.requires_grad, net.get_parameters()), lr, momentum)
+```
-`context.set_auto_parallel_context()` is an API for users to set parallel training parameters and must be called before the initialization of `Model`. If no parameters are specified, MindSpore will automatically set parameters to the empirical values based on the parallel mode. For example, in data parallel mode, `parameter_broadcast` is enabled by default. The related parameters are as follows:
+## Training the Network
-- `parallel_mode`: parallel distributed mode. The default value is `ParallelMode.STAND_ALONE`. The options are `ParallelMode.DATA_PARALLEL` and `ParallelMode.AUTO_PARALLEL`.
-- `parameter_broadcast`: whether to broadcast initialized parameters. The default value is `True` in `DATA_PARALLEL` and `HYBRID_PARALLEL` mode.
-- `mirror_mean`: During backward computation, the framework collects gradients of parameters in data parallel mode across multiple hosts, obtains the global gradient value, and transfers the global gradient value to the optimizer for update. The default value is `False`, which indicates that the `allreduce_sum` operation is applied. The value `True` indicates that the `allreduce_mean` operation is applied.
+`context.set_auto_parallel_context` is an API provided for users to set parallel parameters, which can be invoked only before the initialization of `Model`. If users did not set parameters, MindSpore will automatically set parameters to the empirical values according to the parallel mode. For example, `parameter_broadcast` is `True` in data parallel mode. The parameters are as follows:
-> You are advised to set `device_num` and `global_rank` to their default values. The framework calls the HCCL API to obtain the values.
+- `parallel_mode`: distributed parallel mode. The default value is `ParallelMode.STAND_ALONE`. The options are `ParallelMode.DATA_PARALLEL` and `ParallelMode.AUTO_PARALLEL`.
+- `paramater_broadcast`: specifies whether to broadcast initialized parameters. The Default value is `False` in non-data parallel mode.
+- `mirror_mean`: During backward computation, the framework collects gradients of parameters in data parallel mode across multiple machines, obtains the global gradient value, and transfers the global gradient value to the optimizer for update. The default value is `False`, which indicates the `allreduce_sum` operation that would be applied. And the value `True` indicates the `allreduce_mean` operation that would be applied.
-If multiple network cases exist in the script, call `context.reset_auto_parallel_context()` to restore all parameters to default values before executing the next case.
-In the following sample code, the automatic parallel mode is specified. To switch to the data parallel mode, you only need to change `parallel_mode` to `DATA_PARALLEL`.
+In the following example, the parallel mode is set to `AUTO_PARALLEL`. `dataset_sink_mode=False` indicates that the non-sink mode is used. `LossMonitor` can return the loss value through the callback function.
```python
-from mindspore import context
from mindspore.nn.optim.momentum import Momentum
from mindspore.train.callback import LossMonitor
from mindspore.train.model import Model, ParallelMode
from resnet import resnet50
-device_id = int(os.getenv('DEVICE_ID'))
-context.set_context(mode=context.GRAPH_MODE, device_target="Ascend")
-context.set_context(device_id=device_id) # set device_id
-
-def test_train_cifar(epoch_size=10):
+def test_train_cifar(num_classes=10, epoch_size=10):
context.set_auto_parallel_context(parallel_mode=ParallelMode.AUTO_PARALLEL, mirror_mean=True)
loss_cb = LossMonitor()
- dataset = create_dataset(data_path, epoch_size)
- batch_size = 32
- num_classes = 10
- net = resnet50(batch_size, num_classes)
+ dataset = create_dataset(epoch_size)
+ net = resnet50(32, num_classes)
loss = SoftmaxCrossEntropyExpand(sparse=True)
opt = Momentum(filter(lambda x: x.requires_grad, net.get_parameters()), 0.01, 0.9)
model = Model(net, loss_fn=loss, optimizer=opt)
- model.train(epoch_size, dataset, callbacks=[loss_cb], dataset_sink_mode=True)
+ model.train(epoch_size, dataset, callbacks=[loss_cb], dataset_sink_mode=False)
```
-In the preceding code:
-- `dataset_sink_mode=True`: uses the dataset sink mode. That is, the training computing is sunk to the hardware platform for execution.
-- `LossMonitor`: returns the loss value through the callback function to monitor the loss function.
-
-## Running the Script
-After the script required for training is edited, run the corresponding command to call the script.
-
-Currently, MindSpore distributed execution uses the single-device single-process running mode. That is, one process runs on each device, and the number of total processes is the same as the number of devices that are being used. For device 0, the corresponding process is executed in the foreground. For other devices, the corresponding processes are executed in the background. You need to create a directory for each process to store log information and operator compilation information. The following takes the distributed training script for eight devices as an example to describe how to run the script:
-
-```bash
-#!/bin/bash
-DATA_PATH=$1
-export DATA_PATH=${DATA_PATH}
-RANK_SIZE=$2
-EXEC_PATH=$(pwd)
+## Running Test Cases
-test_dist_8pcs()
-{
- export RANK_TABLE_FILE=${EXEC_PATH}/rank_table_8pcs.json
- export RANK_SIZE=8
-}
-
-test_dist_2pcs()
-{
- export RANK_TABLE_FILE=${EXEC_PATH}/rank_table_2pcs.json
- export RANK_SIZE=2
-}
+Currently, MindSpore distributed execution uses the single-card single-process running mode. The number of processes must be the same as the number of used cards. Each single-process will create a folder to save log and building information. The following is an example of a running script for two-card distributed training:
-test_dist_${RANK_SIZE}pcs
-
-for((i=1;i<${RANK_SIZE};i++))
-do
- rm -rf device$i
- mkdir device$i
- cp ./resnet50_distributed_training.py ./resnet.py ./device$i
- cd ./device$i
- export DEVICE_ID=$i
- export RANK_ID=$i
- echo "start training for device $i"
- env > env$i.log
- pytest -s -v ./resnet50_distributed_training.py > train.log$i 2>&1 &
- cd ../
-done
-rm -rf device0
-mkdir device0
-cp ./resnet50_distributed_training.py ./resnet.py ./device0
-cd ./device0
-export DEVICE_ID=0
-export RANK_ID=0
-echo "start training for device 0"
-env > env0.log
-pytest -s -v ./resnet50_distributed_training.py > train.log0 2>&1
-if [ $? -eq 0 ];then
- echo "training success"
-else
- echo "training failed"
- exit 2
-fi
-cd ../
+```bash
+ #!/bin/bash
+
+ export MINDSPORE_HCCL_CONFIG_PATH=./rank_table.json
+ export RANK_SIZE=2
+ for((i=0;i<$RANK_SIZE;i++))
+ do
+ mkdir device$i
+ cp ./resnet50_distributed_training.py ./device$i
+ cd ./device$i
+ export RANK_ID=$i
+ export DEVICE_ID=$i
+ echo "start training for device $i"
+ env > env$i.log
+ pytest -s -v ./resnet50_distributed_training.py > log$i 2>&1 &
+ cd ../
+ done
```
-The variables `DATA_PATH` and `RANK_SIZE` need to be transferred to the script, which indicate the path of the dataset and the number of devices, respectively.
-
-The necessary environment variables are as follows:
-- `RANK_TABLE_FILE`: path for storing the networking information file.
-- `DEVICE_ID`: actual sequence number of the current device on the corresponding host.
-- `RANK_ID`: logical sequence number of the current device.
-For details about other environment variables, see configuration items in the installation guide.
-
-The running time is about 5 minutes, which is mainly occupied by operator compilation. The actual training time is within 20 seconds. You can use `ps -ef | grep pytest` to monitor task processes.
-
-Log files are saved in the device directory. The env.log file records environment variable information. The train.log file records the loss function information. The following is an example:
-
-```
-epoch: 1 step: 156, loss is 2.0084016
-epoch: 2 step: 156, loss is 1.6407638
-epoch: 3 step: 156, loss is 1.6164391
-epoch: 4 step: 156, loss is 1.6838071
-epoch: 5 step: 156, loss is 1.6320667
-epoch: 6 step: 156, loss is 1.3098773
-epoch: 7 step: 156, loss is 1.3515002
-epoch: 8 step: 156, loss is 1.2943741
-epoch: 9 step: 156, loss is 1.2316195
-epoch: 10 step: 156, loss is 1.1533381
-```
diff --git a/tutorials/source_en/advanced_use/mixed_precision.md b/tutorials/source_en/advanced_use/mixed_precision.md
index 5ff32468c5cb0d015c44c6dc757f4c4ffa223bcf..b88cbd8ec2b4dc17f8dd86e58432df7ab1fd96d7 100644
--- a/tutorials/source_en/advanced_use/mixed_precision.md
+++ b/tutorials/source_en/advanced_use/mixed_precision.md
@@ -37,14 +37,14 @@ This document describes the computation process by using examples of automatic a
## Automatic Mixed Precision
-To use the automatic mixed precision, you need to invoke the corresponding API, which takes the network to be trained and the optimizer as the input. This API converts the operators of the entire network into FP16 operators (except the BatchNorm and Loss operators).
+To use the automatic mixed precision, you need to invoke the corresponding API, which takes the network to be trained and the optimizer as the input. This API converts the operators of the entire network into FP16 operators (except the `BatchNorm` and Loss operators).
The procedure is as follows:
1. Introduce the MindSpore mixed precision API.
2. Define the network. This step is the same as the common network definition. (You do not need to manually configure the precision of any specific operator.)
-3. Use the amp.build_train_network() API to encapsulate the network model and optimizer. In this step, MindSpore automatically converts the operators to the required format.
+3. Use the `amp.build_train_network` API to encapsulate the network model and optimizer. In this step, MindSpore automatically converts the operators to the required format.
A code example is as follows:
@@ -98,7 +98,7 @@ MindSpore also supports manual mixed precision. It is assumed that only one dens
The following is the procedure for implementing manual mixed precision:
1. Define the network. This step is similar to step 2 in the automatic mixed precision.
-2. Configure the mixed precision. Use net.to_float(mstype.float16) to set all operators of the cell and its sub-cells to FP16. Then, configure the dense to FP32.
+2. Configure the mixed precision. Use `net.to_float(mstype.float16)` to set all operators of the cell and its sub-cells to FP16. Then, configure the dense to FP32.
3. Use TrainOneStepCell to encapsulate the network model and optimizer.
diff --git a/tutorials/source_en/advanced_use/model_security.md b/tutorials/source_en/advanced_use/model_security.md
index 3d0909f862e559b96edc1829c8a4684d4eec34b7..4f55cb4c2ebdb10c2cdd10dc942fc503c554c0d4 100644
--- a/tutorials/source_en/advanced_use/model_security.md
+++ b/tutorials/source_en/advanced_use/model_security.md
@@ -69,7 +69,7 @@ TAG = 'demo'
### Loading the Dataset
-Use the MnistDataset API provided by the MindSpore dataset to load the MNIST dataset.
+Use the MnistDataset API provided by the MindSpore dataset to load the `MNIST dataset`.
```python
# generate training data
diff --git a/tutorials/source_en/advanced_use/network_migration.md b/tutorials/source_en/advanced_use/network_migration.md
index d5c91ee3040bcbae535cd818831dc7c4d1312578..acc5fa7b9220ca4a0d20c19053c5589c3bd2b9ed 100644
--- a/tutorials/source_en/advanced_use/network_migration.md
+++ b/tutorials/source_en/advanced_use/network_migration.md
@@ -57,8 +57,6 @@ Prepare the hardware environment, find a platform corresponding to your environm
MindSpore differs from TensorFlow and PyTorch in the network structure. Before migration, you need to clearly understand the original script and information of each layer, such as shape.
-> You can also use [MindConverter Tool](https://gitee.com/mindspore/mindinsight/tree/master/mindinsight/mindconverter) to automatically convert the PyTorch network definition script to MindSpore network definition script.
-
The ResNet-50 network migration and training on the Ascend 910 is used as an example.
1. Import MindSpore modules.
@@ -241,7 +239,7 @@ The ResNet-50 network migration and training on the Ascend 910 is used as an exa
model = Model(net, loss_fn=loss, optimizer=opt, loss_scale_manager=loss_scale, metrics={'acc'})
```
- Similar to `estimator.train()` of TensorFlow, you can call the `model.train` API to perform training. Functions such as CheckPoint and intermediate result printing can be defined on the `model.train` API in Callback mode.
+ Similar to `estimator.train` of TensorFlow, you can call the `model.train` API to perform training. Functions such as CheckPoint and intermediate result printing can be defined on the `model.train` API in Callback mode.
```python
time_cb = TimeMonitor(data_size=step_size)
@@ -268,7 +266,27 @@ Run your scripts on ModelArts. For details, see [Using MindSpore on Cloud](https
### Inference Phase
-Models trained on the Ascend 910 AI processor can be used for inference on different hardware platforms. Refer to the [Multi-platform Inference Tutorial](https://www.mindspore.cn/tutorial/en/master/use/multi_platform_inference.html) for detailed steps.
+Models trained on the Ascend 910 AI processor can be used for inference on different hardware platforms.
+
+1. Inference on the Ascend 910 AI processor
+
+ Similar to the `estimator.evaluate` API of TensorFlow, MindSpore provides the `model.eval` API for model validation. You only need to import the validation dataset. The processing method of the validation dataset is the same as that of the training dataset. For details about the complete code, see .
+
+ ```python
+ res = model.eval(dataset)
+ ```
+
+2. Inference on the Ascend 310 AI processor
+
+ 1. Export the ONNX or GEIR model by referring to the [Export GEIR Model and ONNX Model](https://www.mindspore.cn/tutorial/en/master/use/saving_and_loading_model_parameters.html#geironnx).
+
+ 2. For performing inference in the cloud environment, see the [Ascend 910 training and Ascend 310 inference samples](https://support.huaweicloud.com/bestpractice-modelarts/modelarts_10_0026.html). For details about the bare-metal environment (compared with the cloud environment where the Ascend 310 AI processor is deployed locally), see the description document of the Ascend 310 AI processor software package.
+
+3. Inference on a GPU
+
+ 1. Export the ONNX model by referring to the [Export GEIR Model and ONNX Model](https://www.mindspore.cn/tutorial/en/master/use/saving_and_loading_model_parameters.html#geironnx).
+
+ 2. Perform inference on the NVIDIA GPU by referring to [TensorRT backend for ONNX](https://github.com/onnx/onnx-tensorrt).
## Examples
diff --git a/tutorials/source_en/advanced_use/on_device_inference.md b/tutorials/source_en/advanced_use/on_device_inference.md
index 210fd4985a0e11612c591dd507fa55bb8496eaf4..b3bd3bba9c384ce8b62f63cc24b78988005c4f1c 100644
--- a/tutorials/source_en/advanced_use/on_device_inference.md
+++ b/tutorials/source_en/advanced_use/on_device_inference.md
@@ -95,7 +95,7 @@ To perform on-device model inference using MindSpore, perform the following step
export(net, input_data, file_name="./lenet.ms", file_format='LITE')
```
-Take the LeNet network as an example. The generated on-device model file is `lenet.ms`. The complete sample code lenet.py is as follows:
+Take the LeNet network as an example. The generated on-device model file is `lenet.ms`. The complete sample code `lenet.py` is as follows:
```python
import os
import numpy as np
@@ -230,10 +230,10 @@ Figure 1 On-device inference sequence diagram
outputs.clear();
```
-Select the LeNet network and set the inference input to lenet.bin. The complete sample code lenet.cpp is as follows:
-> MindSpore Predict uses FlatBuffers to define models. The FlatBuffers header file is required for parsing models. Therefore, you need to configure the FlatBuffers header file.
+Select the LeNet network and set the inference input to `lenet.bin`. The complete sample code `lenet.cpp` is as follows:
+> MindSpore Predict uses `FlatBuffers` to define models. The `FlatBuffers` header file is required for parsing models. Therefore, you need to configure the `FlatBuffers` header file.
>
-> Method: Copy the flatbuffers folder in MindSpore root directory/third_party/flatbuffers/include to the directory at the same level as session.h.
+> Method: Copy the `flatbuffers` folder in MindSpore root directory`/third_party/flatbuffers/include` to the directory at the same level as `session.h`.
```cpp
#include
diff --git a/tutorials/source_en/advanced_use/visualization_tutorials.md b/tutorials/source_en/advanced_use/visualization_tutorials.md
index 695b1bcdd8b01a2031e668532557b22a50d388d0..d25d91ddb4f18f4398ffa8c5406ecc9e167f0ea3 100644
--- a/tutorials/source_en/advanced_use/visualization_tutorials.md
+++ b/tutorials/source_en/advanced_use/visualization_tutorials.md
@@ -180,7 +180,7 @@ Use the `save_graphs` option of `context` to record the computational graph afte
### Collect Performance Profile Data
To enable the performance profiling of neural networks, MindInsight Profiler APIs should be added into the script. At first, the MindInsight `Profiler` object need
-to be set after set context and before the network initialization. Then, at the end of the training, `Profiler.analyse()` should be called to finish profiling and generate the perforamnce
+to be set after set context and before the network initialization. Then, at the end of the training, `Profiler.analyse` should be called to finish profiling and generate the perforamnce
analyse results.
The sample code is as follows:
diff --git a/tutorials/source_en/quick_start/quick_start.md b/tutorials/source_en/quick_start/quick_start.md
index 23811b6edacb4e53c4531ad3878ec356d45bca83..4ccc64a1a7ccb81ab78aff8f9f18efa82fcd33bf 100644
--- a/tutorials/source_en/quick_start/quick_start.md
+++ b/tutorials/source_en/quick_start/quick_start.md
@@ -89,7 +89,7 @@ For details about MindSpore modules, search on the [MindSpore API Page](https://
Before compiling code, you need to learn basic information about the hardware and backend required for MindSpore running.
-You can use `context.set_context()` to configure the information required for running, such as the running mode, backend information, and hardware information.
+You can use `context.set_context` to configure the information required for running, such as the running mode, backend information, and hardware information.
Import the `context` module and configure the required information.
@@ -107,7 +107,7 @@ if __name__ == "__main__":
...
```
-This example runs in graph mode. You can configure hardware information based on site requirements. For example, if the code runs on the Ascend AI processor, set `--device_target` to `Ascend`. This rule also applies to the code running on the CPU and GPU. For details about parameters, see the API description for `context.set_context()`.
+This example runs in graph mode. You can configure hardware information based on site requirements. For example, if the code runs on the Ascend AI processor, set `--device_target` to `Ascend`. This rule also applies to the code running on the CPU and GPU. For details about parameters, see the API description for `context.set_context`.
## Processing Data
@@ -115,12 +115,12 @@ Datasets are important for training. A good dataset can effectively improve trai
### Defining the Dataset and Data Operations
-Define the `create_dataset()` function to create a dataset. In this function, define the data augmentation and processing operations to be performed.
+Define the `create_dataset` function to create a dataset. In this function, define the data augmentation and processing operations to be performed.
1. Define the dataset.
2. Define parameters required for data augmentation and processing.
3. Generate corresponding data augmentation operations according to the parameters.
-4. Use the `map()` mapping function to apply data operations to the dataset.
+4. Use the `map` mapping function to apply data operations to the dataset.
5. Process the generated dataset.
```python
@@ -226,7 +226,7 @@ def fc_with_initialize(input_channels, out_channels):
To use MindSpore for neural network definition, inherit `mindspore.nn.cell.Cell`. `Cell` is the base class of all neural networks (such as `Conv2d`).
-Define each layer of a neural network in the `__init__()` method in advance, and then define the `construct()` method to complete the forward construction of the neural network. According to the structure of the LeNet network, define the network layers as follows:
+Define each layer of a neural network in the `__init__` method in advance, and then define the `construct` method to complete the forward construction of the neural network. According to the structure of the LeNet network, define the network layers as follows:
```python
import mindspore.ops.operations as P
@@ -427,7 +427,7 @@ if __name__ == "__main__":
```
In the preceding information:
-`load_checkpoint()`: This API is used to load the CheckPoint model parameter file and return a parameter dictionary.
+`load_checkpoint`: This API is used to load the CheckPoint model parameter file and return a parameter dictionary.
`checkpoint_lenet-3_1404.ckpt`: name of the saved CheckPoint model file.
`load_param_into_net`: This API is used to load parameters to the network.
diff --git a/tutorials/source_en/use/custom_operator.md b/tutorials/source_en/use/custom_operator.md
index 5e2e63207568955857c044719cc183506e9f072b..c93b6ee800517f2d49f7aca6c446cdacb1ee2ed4 100644
--- a/tutorials/source_en/use/custom_operator.md
+++ b/tutorials/source_en/use/custom_operator.md
@@ -34,11 +34,11 @@ This section takes a Square operator as an example to describe how to customize
The primitive of an operator is a subclass inherited from `PrimitiveWithInfer`. The type name of the subclass is the operator name.
The definition of the custom operator primitive is the same as that of the built-in operator primitive.
-- The attribute is defined by the input parameter of the constructor function `__init__()`. The operator in this test case has no attribute. Therefore, `__init__()` has only one input parameter. For details about test cases in which operators have attributes, see [custom add3](https://gitee.com/mindspore/mindspore/tree/master/tests/st/ops/custom_ops_tbe/cus_add3.py) in the MindSpore source code.
-- The input and output names are defined by the `init_prim_io_names()` function.
-- The shape inference method of the output tensor is defined in the `infer_shape()` function, and the dtype inference method of the output tensor is defined in the `infer_dtype()` function.
+- The attribute is defined by the input parameter of the constructor function `__init__`. The operator in this test case has no attribute. Therefore, `__init__` has only one input parameter. For details about test cases in which operators have attributes, see [custom add3](https://gitee.com/mindspore/mindspore/tree/master/tests/st/ops/custom_ops_tbe/cus_add3.py) in the MindSpore source code.
+- The input and output names are defined by the `init_prim_io_names` function.
+- The shape inference method of the output tensor is defined in the `infer_shape` function, and the dtype inference method of the output tensor is defined in the `infer_dtype` function.
-The only difference between a custom operator and a built-in operator is that the operator implementation function (`from square_impl import CusSquareImpl`) needs to be imported to the `__init__()` function to register the operator implementation with the backend for the custom operator. In this test case, the operator implementation and information are defined in `square_impl.py`, and the definition will be described in the following parts.
+The only difference between a custom operator and a built-in operator is that the operator implementation function (`from square_impl import CusSquareImpl`) needs to be imported to the `__init__` function to register the operator implementation with the backend for the custom operator. In this test case, the operator implementation and information are defined in `square_impl.py`, and the definition will be described in the following parts.
The following code takes the Square operator primitive `cus_square.py` as an example:
@@ -74,7 +74,7 @@ The entry function of an operator describes the internal process of compiling th
1. Prepare placeholders to be input. A placeholder will return a tensor object that represents a group of input data.
2. Call the computable function. The computable function uses the API provided by the TBE to describe the computation logic of the operator.
3. Call the scheduling module. The model tiles the operator data based on the scheduling description and specifies the data transfer process to ensure optimal hardware execution. By default, the automatic scheduling module (`auto_schedule`) can be used.
-4. Call `cce_build_code()` to compile and generate an operator binary file.
+4. Call `cce_build_code` to compile and generate an operator binary file.
> The input parameters of the entry function require the input information of each operator, output information of each operator, operator attributes (optional), and kernel_name (name of the generated operator binary file). The input and output information is encapsulated in dictionaries, including the input and output shape and dtype when the operator is called on the network.
For details about TBE operator development, visit the [TBE website](https://www.huaweicloud.com/ascend/tbe). For details about how to debug and optimize the TBE operator, visit the [Mind Studio website](https://www.huaweicloud.com/intl/en-us/ascend/mindstudio).
@@ -85,7 +85,7 @@ The operator information is key for the backend to select the operator implement
> The numbers and sequences of the input and output information defined in the operator information must be the same as those in the parameters of the entry function of the operator implementation and those listed in the operator primitive.
-> If an operator has attributes, use `attr()` to describe the attribute information in the operator information. The attribute names must be the same as those in the operator primitive definition.
+> If an operator has attributes, use `attr` to describe the attribute information in the operator information. The attribute names must be the same as those in the operator primitive definition.
### Example
diff --git a/tutorials/source_en/use/data_preparation/data_processing_and_augmentation.md b/tutorials/source_en/use/data_preparation/data_processing_and_augmentation.md
index 9da14fb7c9b0347214b1ae81ab43415e5efcbc28..60d54a10581d19edda95383ee9268669c0017fca 100644
--- a/tutorials/source_en/use/data_preparation/data_processing_and_augmentation.md
+++ b/tutorials/source_en/use/data_preparation/data_processing_and_augmentation.md
@@ -59,7 +59,7 @@ The following describes how to construct a simple dataset `ds1` and perform data
```python
import mindspore.dataset as ds
```
-2. Define the `generator_func()` function for dataset generating.
+2. Define the `generator_func` function for dataset generating.
```python
def generator_func():
for i in range(5):
@@ -88,7 +88,7 @@ In limited datasets, to optimize the network, a dataset is usually trained for m
> In machine learning, an epoch refers to one cycle through the full training dataset.
-During multiple epochs, `repeat()` can be used to increase the data size. The definition of `repeat()` is as follows:
+During multiple epochs, `repeat` can be used to increase the data size. The definition of `repeat` is as follows:
```python
def repeat(self, count=None):
```
@@ -167,11 +167,11 @@ You can shuffle ordered or repeated datasets.

The shuffle operation is used to shuffle data. A larger value of buffer_size indicates a higher shuffling degree, consuming more time and computing resources.
-The definition of `shuffle()` is as follows:
+The definition of `shuffle` is as follows:
```python
def shuffle(self, buffer_size):
```
-Call `shuffle()` to shuffle the dataset `ds1`. The sample code is as follows:
+Call `shuffle` to shuffle the dataset `ds1`. The sample code is as follows:
```python
print("Before shuffle:")
@@ -200,19 +200,19 @@ After shuffle:
```
### map
The map operation is used to process data. For example, convert the dataset of color images into the dataset of grayscale images. You can flexibly perform the operation as required.
-MindSpore provides the `map()` function to map datasets. You can apply the provided functions or operators to the specified column data.
+MindSpore provides the `map` function to map datasets. You can apply the provided functions or operators to the specified column data.
You can customize the function or use `c_transforms` or `py_transforms` for data augmentation.
> For details about data augmentation operations, see Data Augmentation section.

-The definition of `map()` is as follows:
+The definition of `map` is as follows:
```python
def map(self, input_columns=None, operations=None, output_columns=None, columns_order=None,
num_parallel_workers=None):
```
-In the following example, the `map()` function is used to apply the defined anonymous function (lambda function) to the dataset `ds1` so that the data values in the dataset are multiplied by 2.
+In the following example, the `map` function is used to apply the defined anonymous function (lambda function) to the dataset `ds1` so that the data values in the dataset are multiplied by 2.
```python
func = lambda x : x*2 # Define lambda function to multiply each element by 2.
ds2 = ds1.map(input_columns="data", operations=func)
@@ -228,7 +228,7 @@ The code output is as follows. Data values in each row of the dataset `ds2` is m
[8 10 12]
```
### zip
-MindSpore provides the `zip()` function to combine multiple datasets into one dataset.
+MindSpore provides the `zip` function to combine multiple datasets into one dataset.
> If the column names in the two datasets are the same, the two datasets are not combined. Therefore, pay attention to column names.
> If the number of rows in the two datasets is different, the number of rows after combination is the same as the smaller number.
```python
@@ -267,7 +267,7 @@ MindSpore provides the `c_transforms` and `py_transforms` module functions for u
| `py_transforms` | Python-based [PIL](https://pypi.org/project/Pillow/) implementation | This module provides multiple image augmentation functions and the method for converting between PIL images and NumPy arrays. |
For users who would like to use Python PIL in image learning tasks, the `py_transforms` module is a good tool for image augmentation. You can use Python PIL to customize extensions.
-Data augmentation requires the `map()` function. For details about how to use the `map()` function, see [map](#map).
+Data augmentation requires the `map` function. For details about how to use the `map` function, see [map](#map).
### Using the `c_transforms` Module
@@ -287,7 +287,7 @@ Data augmentation requires the `map()` function. For details about how to use th
imgplot_resized = plt.imshow(data["image"])
plt.show()
```
-The running result shows that the original image is changed from 1024 x 683 pixels to 500 x 500 pixels after data processing by using `Resize()`.
+The running result shows that the original image is changed from 1024 x 683 pixels to 500 x 500 pixels after data processing by using `Resize`.

Figure 1: Original image
@@ -321,7 +321,7 @@ Figure 2: Image after its size is reset
plt.show()
```
-The running result shows that the original image is changed from 1024 x 683 pixels to 500 x 500 pixels after data processing by using `RandomCrop()`.
+The running result shows that the original image is changed from 1024 x 683 pixels to 500 x 500 pixels after data processing by using `RandomCrop`.

Figure 1: Original image
diff --git a/tutorials/source_en/use/multi_platform_inference.md b/tutorials/source_en/use/multi_platform_inference.md
index eb311cca1b51faefe29be5c556c3dd01c97bd7d7..7c42a3fe0ba204812bffdd26441a5efbfe705186 100644
--- a/tutorials/source_en/use/multi_platform_inference.md
+++ b/tutorials/source_en/use/multi_platform_inference.md
@@ -16,13 +16,13 @@ Models based on MindSpore training can be used for inference on different hardwa
1. Inference on the Ascend 910 AI processor
- MindSpore provides the `model.eval()` API for model validation. You only need to import the validation dataset. The processing method of the validation dataset is the same as that of the training dataset. For details about the complete code, see .
+ MindSpore provides the `model.eval` API for model validation. You only need to import the validation dataset. The processing method of the validation dataset is the same as that of the training dataset. For details about the complete code, see .
```python
res = model.eval(dataset)
```
- In addition, the` model.predict ()` interface can be used for inference. For detailed usage, please refer to API description.
+ In addition, the` model.predict` interface can be used for inference. For detailed usage, please refer to API description.
2. Inference on the Ascend 310 AI processor
diff --git a/tutorials/source_en/use/saving_and_loading_model_parameters.md b/tutorials/source_en/use/saving_and_loading_model_parameters.md
index 9732e574324ae96f31e264d9fb8283eee229051d..78fc04726f1a0977a87396c7c0ef02082efb852e 100644
--- a/tutorials/source_en/use/saving_and_loading_model_parameters.md
+++ b/tutorials/source_en/use/saving_and_loading_model_parameters.md
@@ -38,7 +38,7 @@ During model training, use the callback mechanism to transfer the object of the
You can use the `CheckpointConfig` object to set the CheckPoint saving policies.
The saved parameters are classified into network parameters and optimizer parameters.
-`ModelCheckpoint()` provides default configuration policies for users to quickly get started.
+`ModelCheckpoint` provides default configuration policies for users to quickly get started.
The following describes the usage:
```python
from mindspore.train.callback import ModelCheckpoint
diff --git a/tutorials/source_zh_cn/advanced_use/checkpoint_for_hybrid_parallel.md b/tutorials/source_zh_cn/advanced_use/checkpoint_for_hybrid_parallel.md
index 570ea81deaee0d471d83b6e6a96efbb9238d3d1e..3c68fa34cbda7eee8f8e921dcd48ecb4b37b23b4 100644
--- a/tutorials/source_zh_cn/advanced_use/checkpoint_for_hybrid_parallel.md
+++ b/tutorials/source_zh_cn/advanced_use/checkpoint_for_hybrid_parallel.md
@@ -102,8 +102,8 @@ load_param_into_net(net, param_dict)
其中,
-- `load_checkpoint()`:通过该接口加载CheckPoint模型参数文件,返回一个参数字典。
-- `load_param_into_net()`:模型参数数据加载到网络中。
+- `load_checkpoint`:通过该接口加载CheckPoint模型参数文件,返回一个参数字典。
+- `load_param_into_net`:模型参数数据加载到网络中。
- `CKP_1-4_32.ckpt`:之前保存的CheckPoint模型参数文件名称。
> 如果直接在训练环境上,基于当前训练得到的数据直接保存新的CheckPoint文件,参数值已经存在在网络中,则可以省略该步骤,无需导入CheckPoint文件。
@@ -244,7 +244,7 @@ for _, param in net.parameters_and_names():
param_dict = load_checkpoint("./CKP-Integrated_1-4_32.ckpt")
```
-- `load_checkpoint()`:通过该接口加载CheckPoint模型参数文件,返回一个参数字典。
+- `load_checkpoint`:通过该接口加载CheckPoint模型参数文件,返回一个参数字典。
- `CKP-Integrated_1-4_32.ckpt`:需要加载的CheckPoint模型参数文件名称。
### 步骤2:对模型并行参数做切分处理
@@ -425,7 +425,7 @@ load_param_into_net(opt, param_dict)
- `mode=context.GRAPH_MODE`:使用分布式训练需要指定运行模式为图模式(PyNative模式不支持并行)。
- `device_id`:卡物理序号,即卡所在机器中的实际序号。
- - `init()`:完成分布式训练初始化操作。
+ - `init`:完成分布式训练初始化操作。
执行结果:
diff --git a/tutorials/source_zh_cn/advanced_use/customized_debugging_information.md b/tutorials/source_zh_cn/advanced_use/customized_debugging_information.md
index 06981389ccf841235b4ea3bf6b1ef6b918dc77bd..48f0bc2e0d2a4ebda7636b339e56e69679a96e07 100644
--- a/tutorials/source_zh_cn/advanced_use/customized_debugging_information.md
+++ b/tutorials/source_zh_cn/advanced_use/customized_debugging_information.md
@@ -31,7 +31,7 @@ MindSpore提供Callback能力,支持用户在训练/推理的特定阶段,
- MindSpore框架提供的ModelCheckpoint、LossMonitor、SummaryStep等Callback函数。
- MindSpore支持用户自定义Callback。
-使用方法:在model.train方法中传入Callback对象,它可以是一个Callback列表,例:
+使用方法:在`model.train`方法中传入`Callback`对象,它可以是一个`Callback`列表,例:
```python
ckpt_cb = ModelCheckpoint()
@@ -40,14 +40,14 @@ summary_cb = SummaryStep()
model.train(epoch, dataset, callbacks=[ckpt_cb, loss_cb, summary_cb])
```
-ModelCheckpoint可以保存模型参数,以便进行再训练或推理。
-LossMonitor可以在日志中输出loss,方便用户查看,同时它还会监控训练过程中的loss值变化情况,当loss值为`Nan`或`Inf`时终止训练。
+`ModelCheckpoint`可以保存模型参数,以便进行再训练或推理。
+`LossMonitor`可以在日志中输出loss,方便用户查看,同时它还会监控训练过程中的loss值变化情况,当loss值为`Nan`或`Inf`时终止训练。
SummaryStep可以把训练过程中的信息存储到文件中,以便后续进行查看或可视化展示。
-在训练过程中,Callback列表会按照定义的顺序执行Callback函数。因此在定义过程中,需考虑Callback之间的依赖关系。
+在训练过程中,`Callback`列表会按照定义的顺序执行`Callback`函数。因此在定义过程中,需考虑`Callback`之间的依赖关系。
### 自定义Callback
-用户可以基于Callback基类,根据自身的需求,实现自定义Callback。
+用户可以基于`Callback`基类,根据自身的需求,实现自定义`Callback`。
Callback基类定义如下所示:
@@ -79,8 +79,8 @@ class Callback():
pass
```
-Callback可以把训练过程中的重要信息记录下来,通过一个字典类型变量`cb_params`传递给Callback对象,
-用户可以在各个自定义的Callback中获取到相关属性,执行自定义操作。也可以自定义其他变量传递给`cb_params`对象。
+`Callback`可以把训练过程中的重要信息记录下来,通过一个字典类型变量`cb_params`传递给`Callback`对象,
+用户可以在各个自定义的`Callback`中获取到相关属性,执行自定义操作。也可以自定义其他变量传递给`cb_params`对象。
`cb_params`中的主要属性包括:
@@ -126,8 +126,8 @@ model.train(100, dataset, callbacks=stop_cb)
epoch: 20 step: 32 loss: 2.298344373703003
```
-此Callback的功能为:在规定时间内终止训练。通过`run_context.original_args()`方法可以获取到`cb_params`字典,字典里会包含前文描述的主要属性信息。
-同时可以对字典内的值进行修改和添加,上述用例中,在`begin()`中定义一个`init_time`对象传递给`cb_params`字典。
+此Callback的功能为:在规定时间内终止训练。通过`run_context.original_args`方法可以获取到`cb_params`字典,字典里会包含前文描述的主要属性信息。
+同时可以对字典内的值进行修改和添加,上述用例中,在`begin`中定义一个`init_time`对象传递给`cb_params`字典。
在每次`step_end`会做出判断,当训练时间大于设置的时间阈值时,会向`run_context`传递终止训练的信号,提前终止训练,并打印当前的epoch、step、loss的值。
## MindSpore metrics功能介绍
@@ -161,9 +161,9 @@ output = model.eval(ds_eval)
以`accuracy`算子举例说明其内部实现原理:
`accuracy`继承了`EvaluationBase`基类,重写了上述三个方法。
-`clear()`方法会把类中相关计算参数初始化。
-`update()`方法接受预测值和标签值,更新accuracy内部变量。
-`eval()`方法会计算相关指标,返回计算结果。
+`clear`方法会把类中相关计算参数初始化。
+`update`方法接受预测值和标签值,更新accuracy内部变量。
+`eval`方法会计算相关指标,返回计算结果。
调用`accuracy`的`eval`方法,即可得到计算结果。
通过如下代码可以更清楚了解到`accuracy`是如何运行的:
@@ -185,7 +185,7 @@ Accuracy is 0.6667
## print算子功能介绍
MindSpore的自研print算子可以将用户输入的Tensor或字符串信息打印出来,支持多字符串输入,多Tensor输入和字符串与Tensor的混合输入,输入参数以逗号隔开。
-print算子使用方法与其他算子相同,在网络中的`__init__`()声明算子并在`construct()`进行调用,具体使用实例及输出结果如下:
+print算子使用方法与其他算子相同,在网络中的`__init__`声明算子并在`construct`进行调用,具体使用实例及输出结果如下:
```python
import numpy as np
from mindspore import Tensor
@@ -225,7 +225,7 @@ MindSpore采用glog来输出日志,常用的几个环境变量如下:
1. GLOG_v 控制日志的级别,默认值为2,即WARNING级别,对应关系如下:0-DEBUG、1-INFO、2-WARNING、3-ERROR。
2. GLOG_logtostderr 值设置为1时,日志输出到屏幕;值设置为0时,日志输出到文件。默认值为1。
-3. GLOG_log_dir=YourPath 指定日志输出的路径。若GLOG_logtostderr的值为0,则必须设置此变量。若指定了GLOG_log_dir且GLOG_logtostderr的值为1时,则日志输出到屏幕,不输出到文件。C++和Python的日志会被输出到不同的文件中,C++日志的文件名遵从GLOG日志文件的命名规则,这里是`mindspore.机器名.用户名.log.日志级别.时间戳`,Python日志的文件名为`mindspore.log`。
+3. GLOG_log_dir=YourPath 指定日志输出的路径。若`GLOG_logtostderr`的值为0,则必须设置此变量。若指定了`GLOG_log_dir`且`GLOG_logtostderr`的值为1时,则日志输出到屏幕,不输出到文件。C++和Python的日志会被输出到不同的文件中,C++日志的文件名遵从GLOG日志文件的命名规则,这里是`mindspore.机器名.用户名.log.日志级别.时间戳`,Python日志的文件名为`mindspore.log`。
4. MS_SUBMODULE_LOG_v="{SubModule1:LogLevel1,SubModule2:LogLevel2,...}" 指定MindSpore C++各子模块的日志级别,被指定的子模块的日志级别将覆盖GLOG_v在此模块内的设置,此处子模块的日志级别LogLevel与GLOG_v的日志级别含义相同,MindSpore子模块的划分如下表。如可以通过`GLOG_v=1 MS_SUBMODULE_LOG_v="{PARSER:2,ANALYZER:2}"`把`PARSER`和`ANALYZER`模块的日志级别设为WARNING,其他模块的日志级别设为INFO。
> glog不支持日志文件的绕接,如果需要控制日志文件对磁盘空间的占用,可选用操作系统提供的日志文件管理工具,例如:Linux的logrotate。
diff --git a/tutorials/source_zh_cn/advanced_use/debugging_in_pynative_mode.md b/tutorials/source_zh_cn/advanced_use/debugging_in_pynative_mode.md
index 08ac3f3f4d8f89b5fe56791ece4f90250c49d125..51e724227712809f164043adaa4aa4d1da28901e 100644
--- a/tutorials/source_zh_cn/advanced_use/debugging_in_pynative_mode.md
+++ b/tutorials/source_zh_cn/advanced_use/debugging_in_pynative_mode.md
@@ -106,7 +106,7 @@ print(output.asnumpy())
### 提升PyNative性能
-为了提高PyNative模式下的前向计算任务执行速度,MindSpore提供了Staging功能,该功能可以在PyNative模式下将Python函数或者Python类的方法编译成计算图,通过图优化等技术提高运行速度,如下例所示。
+为了提高PyNative模式下的前向计算任务执行速度,MindSpore提供了`Staging`功能,该功能可以在PyNative模式下将Python函数或者Python类的方法编译成计算图,通过图优化等技术提高运行速度,如下例所示。
```python
import numpy as np
diff --git a/tutorials/source_zh_cn/advanced_use/differential_privacy.md b/tutorials/source_zh_cn/advanced_use/differential_privacy.md
index 84c381f7cfc2ade4fe58fe837697b83fb2f81b64..f1c0cc5bb85567b31acc8f551af4bafe671b09a1 100644
--- a/tutorials/source_zh_cn/advanced_use/differential_privacy.md
+++ b/tutorials/source_zh_cn/advanced_use/differential_privacy.md
@@ -25,7 +25,7 @@ $Pr[\mathcal{K}(D)\in S] \le e^{\epsilon} Pr[\mathcal{K}(D') \in S]+\delta$
**MindArmour实现的差分隐私**
-MindArmour的差分隐私模块Differential-Privacy,实现了差分隐私优化器。目前支持基于高斯机制的差分隐私SGD、Momentum、Adam优化器。其中,高斯噪声机制支持固定标准差的非自适应高斯噪声和随着时间或者迭代步数变化而变化的自适应高斯噪声,使用非自适应高斯噪声的优势在于可以严格控制差分隐私预算$\epsilon$,缺点是在模型训练过程中,每个Step添加的噪声量固定,在训练后期,较大的噪声使得模型收敛困难,甚至导致性能大幅下跌,模型可用性差。自适应噪声很好的解决了这个问题,在模型训练初期,添加的噪声量较大,随着模型逐渐收敛,噪声量逐渐减小,噪声对于模型可用性的影响减小。自适应噪声的缺点是不能严格控制差分隐私预算,在同样的初始值下,自适应差分隐私的$\epsilon$比非自适应的大。同时还提供RDP(R’enyi differential privacy)[2]用于监测差分隐私预算。
+MindArmour的差分隐私模块`Differential-Privacy`,实现了差分隐私优化器。目前支持基于高斯机制的差分隐私SGD、Momentum、Adam优化器。其中,高斯噪声机制支持固定标准差的非自适应高斯噪声和随着时间或者迭代步数变化而变化的自适应高斯噪声,使用非自适应高斯噪声的优势在于可以严格控制差分隐私预算$\epsilon$,缺点是在模型训练过程中,每个Step添加的噪声量固定,在训练后期,较大的噪声使得模型收敛困难,甚至导致性能大幅下跌,模型可用性差。自适应噪声很好的解决了这个问题,在模型训练初期,添加的噪声量较大,随着模型逐渐收敛,噪声量逐渐减小,噪声对于模型可用性的影响减小。自适应噪声的缺点是不能严格控制差分隐私预算,在同样的初始值下,自适应差分隐私的`$\epsilon$`比非自适应的大。同时还提供RDP(R’enyi differential privacy)[2]用于监测差分隐私预算。
这里以LeNet模型,MNIST 数据集为例,说明如何在MindSpore上使用差分隐私优化器训练神经网络模型。
@@ -228,7 +228,7 @@ ds_train = generate_mnist_dataset(os.path.join(cfg.data_path, "train"),
1. 配置差分隐私优化器的参数。
- - 判断micro_batches和batch_size参数是否符合要求,batch_size必须要整除micro_batches。
+ - 判断`micro_batches`和`batch_size`参数是否符合要求,`batch_size`必须要整除`micro_batches`。
- 实例化差分隐私工厂类。
- 设置差分隐私的噪声机制,目前mechanisms支持固定标准差的高斯噪声机制:`Gaussian`和自适应调整标准差的高斯噪声机制:`AdaGaussian`。
- 设置优化器类型,目前支持`SGD`、`Momentum`和`Adam`。
diff --git a/tutorials/source_zh_cn/advanced_use/distributed_training.md b/tutorials/source_zh_cn/advanced_use/distributed_training.md
index 0ed78c7f1b9e5ebe6167b50cd0f9837aa9af11c8..db0a957203d99c8c6801c6a416786447b9a06d80 100644
--- a/tutorials/source_zh_cn/advanced_use/distributed_training.md
+++ b/tutorials/source_zh_cn/advanced_use/distributed_training.md
@@ -117,7 +117,7 @@ if __name__ == "__main__":
其中,
- `mode=context.GRAPH_MODE`:使用分布式训练需要指定运行模式为图模式(PyNative模式不支持并行)。
- `device_id`:卡的物理序号,即卡所在机器中的实际序号。
-- `init()`:使能HCCL通信,并完成分布式训练初始化操作。
+- `init`:使能HCCL通信,并完成分布式训练初始化操作。
## 数据并行模式加载数据集
@@ -231,7 +231,7 @@ class SoftmaxCrossEntropyExpand(nn.Cell):
## 训练网络
-`context.set_auto_parallel_context()`是配置并行训练参数的接口,必须在`Model`初始化前调用。如用户未指定参数,框架会自动根据并行模式为用户设置参数的经验值。如数据并行模式下,`parameter_broadcast`默认打开。主要参数包括:
+`context.set_auto_parallel_context`是配置并行训练参数的接口,必须在`Model`初始化前调用。如用户未指定参数,框架会自动根据并行模式为用户设置参数的经验值。如数据并行模式下,`parameter_broadcast`默认打开。主要参数包括:
- `parallel_mode`:分布式并行模式,默认为单机模式`ParallelMode.STAND_ALONE`。可选数据并行`ParallelMode.DATA_PARALLEL`及自动并行`ParallelMode.AUTO_PARALLEL`。
- `parameter_broadcast`: 参数初始化广播开关,`DATA_PARALLEL`和`HYBRID_PARALLEL`模式下,默认值为`True`。
@@ -239,7 +239,7 @@ class SoftmaxCrossEntropyExpand(nn.Cell):
> `device_num`和`global_rank`建议采用默认值,框架内会调用HCCL接口获取。
-如脚本中存在多个网络用例,请在执行下个用例前调用`context.reset_auto_parallel_context()`将所有参数还原到默认值。
+如脚本中存在多个网络用例,请在执行下个用例前调用`context.reset_auto_parallel_context`将所有参数还原到默认值。
在下面的样例中我们指定并行模式为自动并行,用户如需切换为数据并行模式,只需将`parallel_mode`改为`DATA_PARALLEL`。
diff --git a/tutorials/source_zh_cn/advanced_use/mixed_precision.md b/tutorials/source_zh_cn/advanced_use/mixed_precision.md
index 95939b844f94b5cb56c1465a1de43f332459c560..a2d91616a6369e455717055267c21d19a6020da5 100644
--- a/tutorials/source_zh_cn/advanced_use/mixed_precision.md
+++ b/tutorials/source_zh_cn/advanced_use/mixed_precision.md
@@ -14,7 +14,7 @@
## 概述
-混合精度训练方法是通过混合使用单精度和半精度数据格式来加速深度神经网络训练的过程,同时保持了单精度训练所能达到的网络精度。混合精度训练能够加速计算过程,同时减少内存使用和存取,并使得在特定的硬件上可以训练更大的模型或batch size。
+混合精度训练方法是通过混合使用单精度和半精度数据格式来加速深度神经网络训练的过程,同时保持了单精度训练所能达到的网络精度。混合精度训练能够加速计算过程,同时减少内存使用和存取,并使得在特定的硬件上可以训练更大的模型或`batch size`。
对于FP16的算子,若给定的数据类型是FP32,MindSpore框架的后端会进行降精度处理。用户可以开启INFO日志,并通过搜索关键字“reduce precision”查看降精度处理的算子。
@@ -43,7 +43,7 @@ MindSpore混合精度典型的计算流程如下图所示:
2. 定义网络:该步骤和普通的网络定义没有区别(无需手动配置某个算子的精度);
-3. 使用amp.build_train_network()接口封装网络模型、优化器和损失函数,在该步骤中MindSpore会将有需要的算子自动进行类型转换。
+3. 使用`amp.build_train_network`接口封装网络模型、优化器和损失函数,在该步骤中MindSpore会将有需要的算子自动进行类型转换。
代码样例如下:
@@ -97,7 +97,7 @@ MindSpore还支持手动混合精度。假定在网络中只有一个Dense Layer
以下是一个手动混合精度的实现步骤:
1. 定义网络: 该步骤与自动混合精度中的步骤2类似;
-2. 配置混合精度: 通过net.to_float(mstype.float16),把该Cell及其子Cell中所有的算子都配置成FP16;然后,将模型中的dense算子手动配置成FP32;
+2. 配置混合精度: 通过`net.to_float(mstype.float16)`,把该Cell及其子Cell中所有的算子都配置成FP16;然后,将模型中的dense算子手动配置成FP32;
3. 使用TrainOneStepCell封装网络模型和优化器。
diff --git a/tutorials/source_zh_cn/advanced_use/model_security.md b/tutorials/source_zh_cn/advanced_use/model_security.md
index f5420ab586408c8841c15e690cefd98f2a86f44e..9daf517e31f8ea9c295ecc3fc9b993eab417148a 100644
--- a/tutorials/source_zh_cn/advanced_use/model_security.md
+++ b/tutorials/source_zh_cn/advanced_use/model_security.md
@@ -29,8 +29,8 @@ AI算法设计之初普遍未考虑相关的安全威胁,使得AI算法的判
这里通过图像分类任务上的对抗性攻防,以攻击算法FGSM和防御算法NAD为例,介绍MindArmour在对抗攻防上的使用方法。
> 本例面向CPU、GPU、Ascend 910 AI处理器,你可以在这里下载完整的样例代码:
-> - mnist_attack_fgsm.py:包含攻击代码。
-> - mnist_defense_nad.py:包含防御代码。
+> - `mnist_attack_fgsm.py`:包含攻击代码。
+> - `mnist_defense_nad.py`:包含防御代码。
## 建立被攻击模型
@@ -68,7 +68,7 @@ TAG = 'demo'
### 加载数据集
-利用MindSpore的dataset提供的MnistDataset接口加载MNIST数据集。
+利用MindSpore的dataset提供的`MnistDataset`接口加载MNIST数据集。
```python
# generate training data
diff --git a/tutorials/source_zh_cn/advanced_use/network_migration.md b/tutorials/source_zh_cn/advanced_use/network_migration.md
index b427c91d45c24eb8048dce50db6c03c0705138a0..813e094c955760761903b4a8f7c68209f7422ec2 100644
--- a/tutorials/source_zh_cn/advanced_use/network_migration.md
+++ b/tutorials/source_zh_cn/advanced_use/network_migration.md
@@ -237,7 +237,7 @@ MindSpore与TensorFlow、PyTorch在网络结构组织方式上,存在一定差
model = Model(net, loss_fn=loss, optimizer=opt, loss_scale_manager=loss_scale, metrics={'acc'})
```
- 类似于TensorFlow的`estimator.train()`,可以通过调用`model.train`接口来进行训练。CheckPoint和中间结果打印等功能,可通过Callback的方式定义到`model.train`接口上。
+ 类似于TensorFlow的`estimator.train`,可以通过调用`model.train`接口来进行训练。CheckPoint和中间结果打印等功能,可通过`Callback`的方式定义到`model.train`接口上。
```python
time_cb = TimeMonitor(data_size=step_size)
@@ -264,6 +264,27 @@ MindSpore与TensorFlow、PyTorch在网络结构组织方式上,存在一定差
### 推理阶段
在Ascend 910 AI处理器上训练后的模型,支持在不同的硬件平台上执行推理。详细步骤可参考[多平台推理教程](https://www.mindspore.cn/tutorial/zh-CN/master/use/multi_platform_inference.html)。
+在Ascend 910 AI处理器上训练后的模型,支持在不同的硬件平台上执行推理。
+
+1. Ascend 910 AI处理器上推理
+
+ 类似于TensorFlow的`estimator.evaluate`接口,MindSpore提供了`model.eval`接口来进行模型验证,你只需传入验证数据集即可,验证数据集的处理方式与训练数据集相同。完整代码请参考。
+
+ ```python
+ res = model.eval(dataset)
+ ```
+
+2. Ascend 310 AI处理器上推理
+
+ 1. 参考[模型导出](https://www.mindspore.cn/tutorial/zh-CN/master/use/saving_and_loading_model_parameters.html#geironnx)生成ONNX或GEIR模型。
+
+ 2. 云上环境请参考[Ascend910训练和Ascend310推理的样例](https://support.huaweicloud.com/bestpractice-modelarts/modelarts_10_0026.html)完成推理操作。裸机环境(对比云上环境,即本地有Ascend 310 AI 处理器)请参考Ascend 310 AI处理器配套软件包的说明文档。
+
+3. GPU上推理
+
+ 1. 参考[模型导出](https://www.mindspore.cn/tutorial/zh-CN/master/use/saving_and_loading_model_parameters.html#geironnx)生成ONNX模型。
+
+ 2. 参考[TensorRT backend for ONNX](https://github.com/onnx/onnx-tensorrt),在Nvidia GPU上完成推理操作。
## 样例参考
diff --git a/tutorials/source_zh_cn/advanced_use/on_device_inference.md b/tutorials/source_zh_cn/advanced_use/on_device_inference.md
index 17be02578ea5ecdeadb445ff0cc0f7bc628a4e37..6c0fb31c7cc3e865d551c0469feabd8c714c647a 100644
--- a/tutorials/source_zh_cn/advanced_use/on_device_inference.md
+++ b/tutorials/source_zh_cn/advanced_use/on_device_inference.md
@@ -41,7 +41,7 @@ MindSpore Predict是一个轻量级的深度神经网络推理引擎,提供了
- decorator
- scipy
- > numpy, decorator和scipy可以通过pip安装,参考命令如下。
+ > `numpy`, `decorator`和`scipy`可以通过`pip`安装,参考命令如下。
```bash
pip3 install numpy==1.16 decorator scipy
@@ -77,14 +77,14 @@ MindSpore Predict是一个轻量级的深度神经网络推理引擎,提供了
## 端侧推理使用
-在APP的APK工程中使用MindSpore进行模型推理前,需要对输入进行必要的前处理,比如将图片转换成MindSpore推理要求的tensor格式、对图片进行resize等处理。在MindSpore完成模型推理后,对模型推理的结果进行后处理,并将处理的输出发送给APP应用。
+在APP的APK工程中使用MindSpore进行模型推理前,需要对输入进行必要的前处理,比如将图片转换成MindSpore推理要求的`tensor`格式、对图片进行`resize`等处理。在MindSpore完成模型推理后,对模型推理的结果进行后处理,并将处理的输出发送给APP应用。
本章主要描述用户如何使用MindSpore进行模型推理,APK工程的搭建和模型推理的前后处理,不在此列举。
MindSpore进行端侧模型推理的步骤如下。
### 生成端侧模型文件
-1. 加载训练完毕所生成的CheckPoint文件至定义好的网络中。
+1. 加载训练完毕所生成的`CheckPoint`文件至定义好的网络中。
```python
param_dict = load_checkpoint(ckpoint_file_name=ckpt_file_path)
load_param_into_net(net, param_dict)
@@ -94,7 +94,7 @@ MindSpore进行端侧模型推理的步骤如下。
export(net, input_data, file_name="./lenet.ms", file_format='LITE')
```
-以LeNet网络为例,生成的端侧模型文件为`lenet.ms`,完整示例代码lenet.py如下。
+以LeNet网络为例,生成的端侧模型文件为`lenet.ms`,完整示例代码`lenet.py`如下。
```python
import os
import numpy as np
@@ -154,12 +154,12 @@ if __name__ == '__main__':
### 在端侧实现推理
-将.ms模型文件和图片数据作为输入,创建session在端侧实现推理。
+将.ms模型文件和图片数据作为输入,创建`session`在端侧实现推理。

图1:端侧推理时序图
-1. 加载.ms模型文件到内存缓冲区,ReadFile函数功能需要用户参考[C++教程](http://www.cplusplus.com/doc/tutorial/files/)自行实现。
+1. 加载`.ms*`模型文件到内存缓冲区,ReadFile函数功能需要用户参考[C++教程](http://www.cplusplus.com/doc/tutorial/files/)自行实现。
```cpp
// read model file
std::string modelPath = "./models/lenet/lenet.ms";
@@ -169,7 +169,7 @@ if __name__ == '__main__':
char *graphBuf = ReadFile(modelPath.c_str(), graphSize);
```
-2. 调用CreateSession接口创建Session,创建完成后可释放内存缓冲区中的模型文件。
+2. 调用`CreateSession`接口创建`Session`,创建完成后可释放内存缓冲区中的模型文件。
```cpp
// create session
Context ctx;
@@ -177,7 +177,7 @@ if __name__ == '__main__':
free(graphBuf);
```
-3. 从内存缓冲区中读取推理的输入数据,调用SetData()接口将输入数据设置到input tensor中。
+3. 从内存缓冲区中读取推理的输入数据,调用`SetData`接口将输入数据设置到`input tensor`中。
```cpp
// load input buffer
size_t inputSize = 0;
@@ -190,19 +190,19 @@ if __name__ == '__main__':
inputs[0]->SetData(inputBuf);
```
-4. 调用Session中的Run()接口执行推理。
+4. 调用`Session`中的`Run`接口执行推理。
```cpp
// session run
int ret = session->Run(inputs);
```
-5. 调用GetAllOutput()接口获取输出。
+5. 调用`GetAllOutput`接口获取输出。
```cpp
// get output
std::map> outputs = session->GetAllOutput();
```
-6. 调用Tensor的GetData()接口获取输出数据。
+6. 调用`Tensor`的`GetData`接口获取输出数据。
```cpp
// get output data
float *data = nullptr;
@@ -214,7 +214,7 @@ if __name__ == '__main__':
}
```
-7. 推理结束释放input tensor和output tensor。
+7. 推理结束释放`input tensor`和`output tensor`。
```cpp
// free inputs and outputs
for (auto &input : inputs) {
@@ -229,10 +229,10 @@ if __name__ == '__main__':
outputs.clear();
```
-选取LeNet网络,推理输入为“lenet.bin”,完整示例代码lenet.cpp如下。
-> MindSpore Predict使用FlatBuffers定义模型,解析模型需要使用到FlatBuffers头文件,因此用户需要自行配置FlatBuffers头文件。
+选取LeNet网络,推理输入为“`lenet.bin`”,完整示例代码`lenet.cpp`如下。
+> MindSpore Predict使用`FlatBuffers`定义模型,解析模型需要使用到`FlatBuffers`头文件,因此用户需要自行配置`FlatBuffers`头文件。
>
-> 具体做法:将MindSpore根目录/third_party/flatbuffers/include下的flatbuffers文件夹拷贝到session.h的同级目录。
+> 具体做法:将MindSpore根目录`/third_party/flatbuffers/include`下的`flatbuffers`文件夹拷贝到`session.h`的同级目录。
```cpp
#include
diff --git a/tutorials/source_zh_cn/advanced_use/visualization_tutorials.md b/tutorials/source_zh_cn/advanced_use/visualization_tutorials.md
index f41de0c03b787ded3d982b4c3dc8b6ccd471a772..f1a0cdd1bc4f390acf72b62313d5f2667ca84374 100644
--- a/tutorials/source_zh_cn/advanced_use/visualization_tutorials.md
+++ b/tutorials/source_zh_cn/advanced_use/visualization_tutorials.md
@@ -186,7 +186,7 @@ def test_summary():
### 性能数据收集
为了收集神经网络的性能数据,需要在训练脚本中添加MindInsight Profiler接口。首先,在set context之后和初始化网络之前,需要初始化MindInsight `Profiler`对象;
-然后在训练结束后,调用`Profiler.analyse()`停止性能数据收集并生成性能分析结果。
+然后在训练结束后,调用`Profiler.analyse`停止性能数据收集并生成性能分析结果。
样例代码如下:
diff --git a/tutorials/source_zh_cn/quick_start/quick_start.md b/tutorials/source_zh_cn/quick_start/quick_start.md
index 607e132f5f4c33640ee455046cffd8bd2f0dce8f..9268ed3ba13d2f320e331239dace79e88ece61c7 100644
--- a/tutorials/source_zh_cn/quick_start/quick_start.md
+++ b/tutorials/source_zh_cn/quick_start/quick_start.md
@@ -92,7 +92,7 @@ import os
在正式编写代码前,需要了解MindSpore运行所需要的硬件、后端等基本信息。
-可以通过`context.set_context()`来配置运行需要的信息,譬如运行模式、后端信息、硬件等信息。
+可以通过`context.set_context`来配置运行需要的信息,譬如运行模式、后端信息、硬件等信息。
导入`context`模块,配置运行需要的信息。
@@ -110,7 +110,7 @@ if __name__ == "__main__":
...
```
-在样例中我们配置样例运行使用图模式。根据实际情况配置硬件信息,譬如代码运行在Ascend AI处理器上,则`--device_target`选择`Ascend`,代码运行在CPU、GPU同理。详细参数说明,请参见`context.set_context()`接口说明。
+在样例中我们配置样例运行使用图模式。根据实际情况配置硬件信息,譬如代码运行在Ascend AI处理器上,则`--device_target`选择`Ascend`,代码运行在CPU、GPU同理。详细参数说明,请参见`context.set_context`接口说明。
## 数据处理
@@ -118,12 +118,12 @@ if __name__ == "__main__":
### 定义数据集及数据操作
-我们定义一个函数`create_dataset()`来创建数据集。在这个函数中,我们定义好需要进行的数据增强和处理操作:
+我们定义一个函数`create_dataset`来创建数据集。在这个函数中,我们定义好需要进行的数据增强和处理操作:
1. 定义数据集。
2. 定义进行数据增强和处理所需要的一些参数。
3. 根据参数,生成对应的数据增强操作。
-4. 使用`map()`映射函数,将数据操作应用到数据集。
+4. 使用`map`映射函数,将数据操作应用到数据集。
5. 对生成的数据集进行处理。
```python
@@ -229,7 +229,7 @@ def fc_with_initialize(input_channels, out_channels):
使用MindSpore定义神经网络需要继承`mindspore.nn.cell.Cell`。`Cell`是所有神经网络(`Conv2d`等)的基类。
-神经网络的各层需要预先在`__init__()`方法中定义,然后通过定义`construct()`方法来完成神经网络的前向构造。按照LeNet的网络结构,定义网络各层如下:
+神经网络的各层需要预先在`__init__`方法中定义,然后通过定义`construct`方法来完成神经网络的前向构造。按照LeNet的网络结构,定义网络各层如下:
```python
class LeNet5(nn.Cell):
@@ -406,7 +406,7 @@ checkpoint_lenet-1_1875.ckpt
在得到模型文件后,通过模型运行测试数据集得到的结果,验证模型的泛化能力。
-1. 使用`model.eval()`接口读入测试数据集。
+1. 使用`model.eval`接口读入测试数据集。
2. 使用保存后的模型参数进行推理。
```python
@@ -431,7 +431,7 @@ if __name__ == "__main__":
```
其中,
-`load_checkpoint()`:通过该接口加载CheckPoint模型参数文件,返回一个参数字典。
+`load_checkpoint`:通过该接口加载CheckPoint模型参数文件,返回一个参数字典。
`checkpoint_lenet-1_1875.ckpt`:之前保存的CheckPoint模型文件名称。
`load_param_into_net`:通过该接口把参数加载到网络中。
diff --git a/tutorials/source_zh_cn/use/custom_operator.md b/tutorials/source_zh_cn/use/custom_operator.md
index 18004d1f8817d6f9a7f32095065aa4da4e16ecc8..01990d59ae72b3ef74812637c7d654ecccb9d0d0 100644
--- a/tutorials/source_zh_cn/use/custom_operator.md
+++ b/tutorials/source_zh_cn/use/custom_operator.md
@@ -34,11 +34,11 @@
每个算子的原语是一个继承于`PrimitiveWithInfer`的子类,其类型名称即是算子名称。
自定义算子原语与内置算子原语的接口定义完全一致:
-- 属性由构造函数`__init__()`的入参定义。本用例的算子没有属性,因此`__init__()`没有额外的入参。带属性的用例可参考MindSpore源码中的[custom add3](https://gitee.com/mindspore/mindspore/tree/master/tests/st/ops/custom_ops_tbe/cus_add3.py)用例。
-- 输入输出的名称通过`init_prim_io_names()`函数定义。
-- 输出Tensor的shape推理方法在`infer_shape()`函数中定义,输出Tensor的dtype推理方法在`infer_dtype()`函数中定义。
+- 属性由构造函数`__init__`的入参定义。本用例的算子没有属性,因此`__init__`没有额外的入参。带属性的用例可参考MindSpore源码中的[custom add3](https://gitee.com/mindspore/mindspore/tree/master/tests/st/ops/custom_ops_tbe/cus_add3.py)用例。
+- 输入输出的名称通过`init_prim_io_names`函数定义。
+- 输出Tensor的shape推理方法在`infer_shape`函数中定义,输出Tensor的dtype推理方法在`infer_dtype`函数中定义。
-自定义算子与内置算子的唯一区别是需要通过在`__init__()`函数中导入算子实现函数(`from square_impl import CusSquareImpl`)来将算子实现注册到后端。本用例在`square_impl.py`中定义了算子实现和算子信息,将在后文中说明。
+自定义算子与内置算子的唯一区别是需要通过在`__init__`函数中导入算子实现函数(`from square_impl import CusSquareImpl`)来将算子实现注册到后端。本用例在`square_impl.py`中定义了算子实现和算子信息,将在后文中说明。
以Square算子原语`cus_square.py`为例,给出如下示例代码。
@@ -74,7 +74,7 @@ class CusSquare(PrimitiveWithInfer):
1. 准备输入的placeholder,placeholder是一个占位符,返回一个Tensor对象,表示一组输入数据。
2. 调用计算函数,计算函数使用TBE提供的API接口描述了算子内部的计算逻辑。
3. 调用Schedule调度模块,调度模块对算子中的数据按照调度模块的调度描述进行切分,同时指定好数据的搬运流程,确保在硬件上的执行达到最优。默认可以采用自动调度模块(`auto_schedule`)。
-4. 调用`cce_build_code()`编译生成算子二进制。
+4. 调用`cce_build_code`编译生成算子二进制。
> 入口函数的输入参数有特殊要求,需要依次为:算子每个输入的信息、算子每个输出的信息、算子属性(可选)和kernel_name(生成算子二进制的名称)。输入和输出的信息用字典封装传入,其中包含该算子在网络中被调用时传入的实际输入和输出的shape和dtype。
更多关于使用TBE开发算子的内容请参考[TBE文档](https://www.huaweicloud.com/ascend/tbe),关于TBE算子的调试和性能优化请参考[MindStudio文档](https://www.huaweicloud.com/ascend/mindstudio)。
@@ -84,7 +84,7 @@ class CusSquare(PrimitiveWithInfer):
算子信息是指导后端选择算子实现的关键信息,同时也指导后端为算子插入合适的类型和格式转换。它通过`TBERegOp`接口定义,通过`op_info_register`装饰器将算子信息与算子实现入口函数绑定。当算子实现py文件被导入时,`op_info_register`装饰器会将算子信息注册到后端的算子信息库中。更多关于算子信息的使用方法请参考`TBERegOp`的成员方法的注释说明。
> - 算子信息中定义输入输出信息的个数和顺序、算子实现入口函数的参数中的输入输出信息的个数和顺序、算子原语中输入输出名称列表的个数和顺序,三者要完全一致。
-> - 算子如果带属性,在算子信息中需要用`attr()`描述属性信息,属性的名称与算子原语定义中的属性名称要一致。
+> - 算子如果带属性,在算子信息中需要用`attr`描述属性信息,属性的名称与算子原语定义中的属性名称要一致。
### 示例
diff --git a/tutorials/source_zh_cn/use/data_preparation/converting_datasets.md b/tutorials/source_zh_cn/use/data_preparation/converting_datasets.md
index 93634166c29eaec6dbfd8451f65115ee769dbede..7bd585166ad30dc26656b09a6686fd7cacc8b398 100644
--- a/tutorials/source_zh_cn/use/data_preparation/converting_datasets.md
+++ b/tutorials/source_zh_cn/use/data_preparation/converting_datasets.md
@@ -47,7 +47,7 @@ MindSpore提供写操作工具,可将用户定义的原始数据写为MindSpor
字段属性type:int32、int64、float32、float64、string、bytes。
字段属性shape:[...], ...可以是一维数组,用[-1]表示; 可以是二维数组,用[m, n]表示;可以是三维数组,用[x, y, z]表示。
> 1. 如果字段有属性Shape,暂时只支持type为int32、int64、float32、float64类型。
- > 2. 如果字段有属性Shape,则用户在准备数据并传入write_raw_data接口时必须是numpy.ndarray类型。
+ > 2. 如果字段有属性Shape,则用户在准备数据并传入`write_raw_data`接口时必须是`numpy.ndarray`类型。
举例:
- 图片分类
diff --git a/tutorials/source_zh_cn/use/data_preparation/data_processing_and_augmentation.md b/tutorials/source_zh_cn/use/data_preparation/data_processing_and_augmentation.md
index ee3ae3d198d1be2f5111cbaedaa89f305070d4f5..f9ff8473130f305a369aabdeef75f11be7689b15 100644
--- a/tutorials/source_zh_cn/use/data_preparation/data_processing_and_augmentation.md
+++ b/tutorials/source_zh_cn/use/data_preparation/data_processing_and_augmentation.md
@@ -88,7 +88,7 @@ ds1 = ds1.repeat(10)
> 在机器学习中,每训练完一个完整的数据集,我们称为训练完了一个epoch。
-加倍数据集,通常用在多个epoch(迭代)训练中,通过`repeat()`来加倍数据量。`repeat()`定义如下:
+加倍数据集,通常用在多个epoch(迭代)训练中,通过`repeat`来加倍数据量。`repeat`定义如下:
```python
def repeat(self, count=None):
```
@@ -118,7 +118,7 @@ ds2:
[4 5 6]
```
### batch
-将数据集进行分批。在实际训练中,可将数据分批处理,将几个数据作为1组,进行训练,减少训练轮次,达到加速训练过程的目的。MindSpore通过`batch()`函数来实现数据集分批,函数定义如下:
+将数据集进行分批。在实际训练中,可将数据分批处理,将几个数据作为1组,进行训练,减少训练轮次,达到加速训练过程的目的。MindSpore通过`batch`函数来实现数据集分批,函数定义如下:

@@ -166,11 +166,11 @@ batch size:3 drop remainder:True

shuffle操作主要用来将数据混洗,设定的buffer_size越大,混洗程度越大,但时间、计算资源消耗会大。
-`shuffle()`定义如下:
+`shuffle`定义如下:
```python
def shuffle(self, buffer_size):
```
-调用`shuffle()`对数据集`ds1`进行混洗,示例代码如下:
+调用`shuffle`对数据集`ds1`进行混洗,示例代码如下:
```python
print("Before shuffle:")
@@ -199,7 +199,7 @@ After shuffle:
```
### map
map(映射)即对数据进行处理,譬如将彩色图片的数据集转化为灰色图片的数据集等,应用非常灵活。
-MindSpore提供`map()`函数对数据集进行映射操作,用户可以将提供的函数或算子作用于指定的列数据。
+MindSpore提供`map`函数对数据集进行映射操作,用户可以将提供的函数或算子作用于指定的列数据。
用户可以自定义函数,也可以直接使用`c_transforms`或`py_transforms`做数据增强。
> 详细的数据增强操作,将在文后数据增强章节进行介绍。
@@ -227,7 +227,7 @@ for data in ds2.create_dict_iterator():
[8 10 12]
```
### zip
-MindSpore提供`zip()`函数,可将多个数据集合并成1个数据集。
+MindSpore提供`zip`函数,可将多个数据集合并成1个数据集。
> 如果两个数据集的列名相同,则不会合并,请注意列的命名。
> 如果两个数据集的行数不同,合并后的行数将和较小行数保持一致。
```python
@@ -242,7 +242,7 @@ def zip(self, datasets):
ds2 = ds.GeneratorDataset(generator_func2, ["data2"])
```
-2. 通过`zip()`将数据集`ds1`的`data1`列和数据集`ds2`的`data2`列合并成数据集`ds3`。
+2. 通过`zip`将数据集`ds1`的`data1`列和数据集`ds2`的`data2`列合并成数据集`ds3`。
```python
ds3 = ds.zip((ds1, ds2))
for data in ds3.create_dict_iterator():
@@ -266,7 +266,7 @@ MindSpore提供`c_transforms`模块以及`py_transforms`模块函数供用户进
| `py_transforms` | 基于Python的[PIL](https://pypi.org/project/Pillow/)实现 | 该模块提供了多种图像增强功能,并提供了PIL Image和numpy数组之间的传输方法。 |
对于喜欢在图像学习任务中使用Python PIL的用户,`py_transforms`模块是处理图像增强的好工具。用户还可以使用Python PIL自定义自己的扩展。
-数据增强需要使用`map()`函数,详细`map()`函数的使用,可参考[map](#map)章节。
+数据增强需要使用`map`函数,详细`map`函数的使用,可参考[map](#map)章节。
### 使用`c_transforms`模块进行数据增强
@@ -286,7 +286,7 @@ MindSpore提供`c_transforms`模块以及`py_transforms`模块函数供用户进
imgplot_resized = plt.imshow(data["image"])
plt.show()
```
-运行结果可以看到,原始图片与进行数据处理(`Resize()`)后的图片对比,可以看到图片由原来的1024\*683像素,变化为500\*500像素。
+运行结果可以看到,原始图片与进行数据处理(`Resize`)后的图片对比,可以看到图片由原来的1024\*683像素,变化为500\*500像素。

图1:原始图片
@@ -320,7 +320,7 @@ MindSpore提供`c_transforms`模块以及`py_transforms`模块函数供用户进
plt.show()
```
-运行结果可以看到,原始图片与进行数据处理(`RandomCrop()`)后的图片对比,可以看到图片由原来的1024\*683像素,变化为500\*500像素。
+运行结果可以看到,原始图片与进行数据处理(`RandomCrop`)后的图片对比,可以看到图片由原来的1024\*683像素,变化为500\*500像素。

图1:原始图片
diff --git a/tutorials/source_zh_cn/use/multi_platform_inference.md b/tutorials/source_zh_cn/use/multi_platform_inference.md
index f1b8f5a219ca32f2edba1c34f5f42a41a01e900f..c1254d3ef8f4e78ef3caf57b049367ff374e4f74 100644
--- a/tutorials/source_zh_cn/use/multi_platform_inference.md
+++ b/tutorials/source_zh_cn/use/multi_platform_inference.md
@@ -19,13 +19,13 @@
## Ascend 910 AI处理器上推理
-MindSpore提供了`model.eval()`接口来进行模型验证,你只需传入验证数据集即可,验证数据集的处理方式与训练数据集相同。完整代码请参考。
+MindSpore提供了`model.eval`接口来进行模型验证,你只需传入验证数据集即可,验证数据集的处理方式与训练数据集相同。完整代码请参考。
```python
res = model.eval(dataset)
```
-此外,也可以通过`model.predict()`接口来进行推理操作,详细用法可参考API说明。
+此外,也可以通过`model.predict`接口来进行推理操作,详细用法可参考API说明。
## Ascend 310 AI处理器上推理
diff --git a/tutorials/source_zh_cn/use/saving_and_loading_model_parameters.md b/tutorials/source_zh_cn/use/saving_and_loading_model_parameters.md
index b5822be706518c0502cbc68fdc12dcc61361b4e6..dc4848e1872805f99426f8cd7ec15baa30b076c2 100644
--- a/tutorials/source_zh_cn/use/saving_and_loading_model_parameters.md
+++ b/tutorials/source_zh_cn/use/saving_and_loading_model_parameters.md
@@ -38,7 +38,7 @@ CheckPoint的protocol格式定义在`mindspore/ccsrc/utils/checkpoint.proto`中
通过`CheckpointConfig`对象可以设置CheckPoint的保存策略。
保存的参数分为网络参数和优化器参数。
-`ModelCheckpoint()`提供默认配置策略,方便用户快速上手。
+`ModelCheckpoint`提供默认配置策略,方便用户快速上手。
具体用法如下:
```python
from mindspore.train.callback import ModelCheckpoint