From 2e3f9bc4e49aa9cb222e96aaac2fbd72d42513b6 Mon Sep 17 00:00:00 2001 From: leiyuning Date: Fri, 3 Apr 2020 16:17:06 +0800 Subject: [PATCH] add hardware info --- .../advanced_use/computer_vision_application.md | 2 +- .../source_en/advanced_use/distributed_training.md | 5 +---- tutorials/source_en/advanced_use/model_security.md | 6 +++--- tutorials/source_en/advanced_use/nlp_application.md | 10 +++------- .../advanced_use/computer_vision_application.md | 2 +- .../source_zh_cn/advanced_use/distributed_training.md | 4 +--- tutorials/source_zh_cn/advanced_use/model_security.md | 7 ++++--- .../source_zh_cn/advanced_use/nlp_application.md | 11 ++++------- .../use/data_preparation/loading_the_datasets.md | 2 +- .../resnet50_distributed_training.py | 4 +++- tutorials/tutorial_code/lenet.py | 4 +++- tutorials/tutorial_code/lstm/main.py | 1 + .../tutorial_code/model_safety/mnist_attack_fgsm.py | 4 ++++ .../tutorial_code/model_safety/mnist_defense_nad.py | 4 +++- tutorials/tutorial_code/resnet/cifar_resnet50.py | 4 +++- tutorials/tutorial_code/resnet/resnet.py | 4 +++- 16 files changed, 39 insertions(+), 35 deletions(-) diff --git a/tutorials/source_en/advanced_use/computer_vision_application.md b/tutorials/source_en/advanced_use/computer_vision_application.md index 0f2359f3..5909f93b 100644 --- a/tutorials/source_en/advanced_use/computer_vision_application.md +++ b/tutorials/source_en/advanced_use/computer_vision_application.md @@ -62,7 +62,7 @@ Next, let's use MindSpore to solve the image classification task. The overall pr 5. Call the high-level `Model` API to train and save the model file. 6. Load the saved model for inference. -> This example is for the hardware platform of the Ascend 910 AI processor, download the complete code at . +> This example is for the hardware platform of the Ascend 910 AI processor. You can find the complete executable sample code at: . The key parts of the task process code are explained below. diff --git a/tutorials/source_en/advanced_use/distributed_training.md b/tutorials/source_en/advanced_use/distributed_training.md index 7d859196..b2465081 100644 --- a/tutorials/source_en/advanced_use/distributed_training.md +++ b/tutorials/source_en/advanced_use/distributed_training.md @@ -28,11 +28,8 @@ Among them: - 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. In this tutorial, we will learn how to train the ResNet-50 network in `DATA_PARALLEL` or `AUTO_PARALLEL` mode on MindSpore. -For sample code, please see at -. - -> The current sample is for the Ascend AI processor. +> The current sample is for the Ascend 910 AI processor. You can find the complete executable sample code at:. ## Preparations diff --git a/tutorials/source_en/advanced_use/model_security.md b/tutorials/source_en/advanced_use/model_security.md index 98b941af..5a3a09f3 100644 --- a/tutorials/source_en/advanced_use/model_security.md +++ b/tutorials/source_en/advanced_use/model_security.md @@ -27,9 +27,9 @@ At the beginning of AI algorithm design, related security threats are sometimes This section describes how to use MindArmour in adversarial attack and defense by taking the Fast Gradient Sign Method (FGSM) attack algorithm and Natural Adversarial Defense (NAD) algorithm as examples. -> You can find the complete executable sample code at -> -> and +> The current sample is for CPU, GPU and Ascend 910 AI processor. You can find the complete executable sample code at: +> - mnist_attack_fgsm.py: contains attack code. +> - mnist_defense_nad.py: contains defense code. ## Creating an Target Model diff --git a/tutorials/source_en/advanced_use/nlp_application.md b/tutorials/source_en/advanced_use/nlp_application.md index a9944dbc..9ec0a1de 100644 --- a/tutorials/source_en/advanced_use/nlp_application.md +++ b/tutorials/source_en/advanced_use/nlp_application.md @@ -17,7 +17,6 @@ - [Training and Saving the Model](#training-and-saving-the-model) - [Validating the Model](#validating-the-model) - [Experiment Result](#experiment-result) - - [Downloading Code](#downloading-code) @@ -84,6 +83,9 @@ Currently, MindSpore GPU supports the long short-term memory (LSTM) network for Long short-term memory (LSTM) is an artificial recurrent neural network (RNN) architecture used for processing and predicting an important event with a long interval and delay in a time sequence. For details, refer to online documentation. 3. After the model is obtained, use the validation dataset to check the accuracy of model. +> The current sample is for the Ascend 910 AI processor. You can find the complete executable sample code at: +> - main.py: code file, including code for data preprocessing, network definition, and model training. +> - config.py: some configurations on the network, including the batch size and number of training epochs. ## Implementation @@ -531,9 +533,3 @@ RegisterOperatorCreator:OperatorCreators init ============== Accuracy:{'acc': 0.8599358974358975} ============== ``` -## Downloading Code -Complete and executable code download address: - -- main.py: code file, including code for data preprocessing, network definition, and model training. -- config.py: some configurations on the network, including the batch size and number of training epochs. - diff --git a/tutorials/source_zh_cn/advanced_use/computer_vision_application.md b/tutorials/source_zh_cn/advanced_use/computer_vision_application.md index e6ad3d3c..007cbcdb 100644 --- a/tutorials/source_zh_cn/advanced_use/computer_vision_application.md +++ b/tutorials/source_zh_cn/advanced_use/computer_vision_application.md @@ -63,7 +63,7 @@ MindSpore当前支持的图像分类网络包括:典型网络LeNet、AlexNet 6. 加载保存的模型进行推理 -> 本例面向Ascend 910 AI处理器硬件平台,样例的完整代码下载 +> 本例面向Ascend 910 AI处理器硬件平台,你可以在这里下载完整的样例代码: 下面对任务流程中各个环节及代码关键片段进行解释说明。 diff --git a/tutorials/source_zh_cn/advanced_use/distributed_training.md b/tutorials/source_zh_cn/advanced_use/distributed_training.md index b5b097b7..7c3d9485 100644 --- a/tutorials/source_zh_cn/advanced_use/distributed_training.md +++ b/tutorials/source_zh_cn/advanced_use/distributed_training.md @@ -28,9 +28,7 @@ MindSpore支持数据并行及自动并行。自动并行是MindSpore融合了 - 代价模型(Cost Model):同时考虑内存的计算代价和通信代价对训练时间建模,并设计了高效的算法来找到训练时间较短的并行策略。 本篇教程我们主要了解如何在MindSpore上通过数据并行及自动并行模式训练ResNet-50网络。 -样例代码请参考 。 - -> 当前样例面向Ascend AI处理器。 +> 本例面向Ascend 910 AI处理器硬件平台,你可以在这里下载完整的样例代码: ## 准备环节 diff --git a/tutorials/source_zh_cn/advanced_use/model_security.md b/tutorials/source_zh_cn/advanced_use/model_security.md index 290ce420..2e3d7de9 100644 --- a/tutorials/source_zh_cn/advanced_use/model_security.md +++ b/tutorials/source_zh_cn/advanced_use/model_security.md @@ -25,9 +25,10 @@ AI算法设计之初普遍未考虑相关的安全威胁,使得AI算法的判 - 评估模块提供多种指标全面评估对抗样本攻防性能。 这里通过图像分类任务上的对抗性攻防,以攻击算法FGSM和防御算法NAD为例,介绍MindArmour在对抗攻防上的使用方法。 -> 你可以在这里找到完整可运行的样例代码: -> 攻击代码: -> 防御代码: + +> 本例面向CPU、GPU、Ascend 910 AI处理器,你可以在这里下载完整的样例代码: +> - mnist_attack_fgsm.py:包含攻击代码。 +> - mnist_defense_nad.py:包含防御代码。 ## 建立被攻击模型 diff --git a/tutorials/source_zh_cn/advanced_use/nlp_application.md b/tutorials/source_zh_cn/advanced_use/nlp_application.md index 7e9ef8ce..bc4c7bb1 100644 --- a/tutorials/source_zh_cn/advanced_use/nlp_application.md +++ b/tutorials/source_zh_cn/advanced_use/nlp_application.md @@ -17,7 +17,6 @@ - [训练并保存模型](#训练并保存模型) - [模型验证](#模型验证) - [实验结果](#实验结果) - - [下载代码](#下载代码) @@ -78,13 +77,15 @@ $F1分数 = (2 * Precision * Recall) / (Precision + Recall)$ ### 确定网络及流程 -当前,MindSpore GPU版本支持LSTM网络,我们使用LSTM网络进行自然语言处理。 +我们使用LSTM网络进行自然语言处理。 1. 加载使用的数据集,并进行必要的数据处理。 2. 使用LSTM网络训练数据,生成模型。 > LSTM(Long short-term memory,长短期记忆)网络是一种时间循环神经网络,适合于处理和预测时间序列中间隔和延迟非常长的重要事件。具体介绍可参考网上资料,在此不再赘述。 3. 得到模型之后,使用验证数据集,查看模型精度情况。 - +> 本例面向GPU硬件平台,你可以在这里下载完整的样例代码: +> - main.py:代码文件,包括数据预处理、网络定义、模型训练等代码。 +> - config.py:网络中的一些配置,包括batch size、进行几次epoch训练等。 ## 实现阶段 ### 导入需要的库文件 @@ -531,9 +532,5 @@ RegisterOperatorCreator:OperatorCreators init ============== Accuracy:{'acc': 0.8599358974358975} ============== ``` -## 下载代码 -完整可运行代码下载地址: -- main.py:代码文件,包括数据预处理、网络定义、模型训练等代码。 -- config.py:网络中的一些配置,包括batch size、进行几次epoch训练等。 diff --git a/tutorials/source_zh_cn/use/data_preparation/loading_the_datasets.md b/tutorials/source_zh_cn/use/data_preparation/loading_the_datasets.md index dfe7edb6..f46f84ae 100644 --- a/tutorials/source_zh_cn/use/data_preparation/loading_the_datasets.md +++ b/tutorials/source_zh_cn/use/data_preparation/loading_the_datasets.md @@ -28,7 +28,7 @@ MindSpore可以加载常见的标准数据集。支持的数据集如下表: | ImageNet | ImageNet是根据WordNet层次结构组织的图像数据库,其中层次结构的每个节点都由成百上千个图像表示。 | | MNIST | 是一个手写数字图像的大型数据库,通常用于训练各种图像处理系统。 | | CIFAR-10 | 常用于训练图像的采集机器学习和计算机视觉算法。CIFAR-10数据集包含10种不同类别的60,000张32x32彩色图像。 | -| CIFAR-100 | 该数据集类似于CIFAR-10,不同之处在于它有100个类别,每个类别包含600张图像。每个课程有500张训练图像和100张测试图像。 | +| CIFAR-100 | 该数据集类似于CIFAR-10,不同之处在于它有100个类别,每个类别包含600张图像:500张训练图像和100张测试图像。 | | PASCAL-VOC | 数据内容多样,可用于训练计算机视觉模型(分类、定位、检测、分割、动作识别等)。 | | CelebA | CelebA人脸数据集包含上万个名人身份的人脸图片,每张图片有40个特征标记,常用于人脸相关的训练任务。 | diff --git a/tutorials/tutorial_code/distributed_training/resnet50_distributed_training.py b/tutorials/tutorial_code/distributed_training/resnet50_distributed_training.py index 2db51110..284f7e4d 100644 --- a/tutorials/tutorial_code/distributed_training/resnet50_distributed_training.py +++ b/tutorials/tutorial_code/distributed_training/resnet50_distributed_training.py @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -"""resnet50_distributed_training""" +"""resnet50_distributed_training +The sample can be run on Ascend 910 AI processor. +""" import os import random import argparse diff --git a/tutorials/tutorial_code/lenet.py b/tutorials/tutorial_code/lenet.py index f3899de1..f08975f5 100644 --- a/tutorials/tutorial_code/lenet.py +++ b/tutorials/tutorial_code/lenet.py @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -"""Lenet Tutorial""" +"""Lenet Tutorial +The sample can be run on CPU, GPU and Ascend 910 AI processor. +""" import os import urllib.request from urllib.parse import urlparse diff --git a/tutorials/tutorial_code/lstm/main.py b/tutorials/tutorial_code/lstm/main.py index 4cccb982..dde13eb8 100644 --- a/tutorials/tutorial_code/lstm/main.py +++ b/tutorials/tutorial_code/lstm/main.py @@ -14,6 +14,7 @@ # ============================================================================ """ LSTM Tutorial +The sample can be run on GPU. """ import os import shutil diff --git a/tutorials/tutorial_code/model_safety/mnist_attack_fgsm.py b/tutorials/tutorial_code/model_safety/mnist_attack_fgsm.py index 8d087242..9561b5ce 100644 --- a/tutorials/tutorial_code/model_safety/mnist_attack_fgsm.py +++ b/tutorials/tutorial_code/model_safety/mnist_attack_fgsm.py @@ -11,6 +11,10 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. +""" +mnist_attack_fgsm +The sample can be run on Ascend 910 AI processor. +""" import sys import time import numpy as np diff --git a/tutorials/tutorial_code/model_safety/mnist_defense_nad.py b/tutorials/tutorial_code/model_safety/mnist_defense_nad.py index 36b5417c..a76c2a60 100644 --- a/tutorials/tutorial_code/model_safety/mnist_defense_nad.py +++ b/tutorials/tutorial_code/model_safety/mnist_defense_nad.py @@ -11,7 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -"""defense example using nad""" +"""Defense example using nad +The sample can be run on CPU, GPU and Ascend 910 AI processor. +""" import sys import logging diff --git a/tutorials/tutorial_code/resnet/cifar_resnet50.py b/tutorials/tutorial_code/resnet/cifar_resnet50.py index da0620b7..e5db6607 100644 --- a/tutorials/tutorial_code/resnet/cifar_resnet50.py +++ b/tutorials/tutorial_code/resnet/cifar_resnet50.py @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -'''cifar_resnet50''' +'''cifar_resnet50 +The sample can be run on Ascend 910 AI processor. +''' import os import random import argparse diff --git a/tutorials/tutorial_code/resnet/resnet.py b/tutorials/tutorial_code/resnet/resnet.py index 82434acd..d0155563 100644 --- a/tutorials/tutorial_code/resnet/resnet.py +++ b/tutorials/tutorial_code/resnet/resnet.py @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -'''resnet''' +'''resnet +The sample can be run on Ascend 910 AI processor. +''' import numpy as np import mindspore.nn as nn from mindspore import Tensor -- GitLab