提交 6258bfd3 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!346 amend the notebook for MindInsight and network_list to master

Merge pull request !346 from zhangyi/MindInsightDoc_Add
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
<a href="https://gitee.com/mindspore/docs/tree/master/docs/source_zh_cn/network_list.md" target="_blank"><img src="./_static/logo_source.png"></a> <a href="https://gitee.com/mindspore/docs/tree/master/docs/source_zh_cn/network_list.md" target="_blank"><img src="./_static/logo_source.png"></a>
## Model Zoo ## Model Zoo
| 领域 | 子领域 | 网络 | Ascend | GPU | CPU | 领域 | 子领域 | 网络 | Ascend | GPU | CPU
|:------ |:------| :----------- |:------ |:------ |:----- |:------ |:------| :----------- |:------ |:------ |:-----
|计算机视觉(CV) | 图像分类(Image Classification) | [AlexNet](https://gitee.com/mindspore/mindspore/blob/master/model_zoo/alexnet/src/alexnet.py) | Supported | Supported | Doing |计算机视觉(CV) | 图像分类(Image Classification) | [AlexNet](https://gitee.com/mindspore/mindspore/blob/master/model_zoo/alexnet/src/alexnet.py) | Supported | Supported | Doing
......
...@@ -4,21 +4,25 @@ ...@@ -4,21 +4,25 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"# MindInsight之标量、直方图和图像\n", "# 标量、直方图和图像可视化\n",
"\n", "\n",
"MindInsight可以将神经网络训练过程中的损失值标量、直方图、图像信息记录到日志文件中,通过可视化界面解析以供用户查看。\n", "MindInsight可以将神经网络训练过程中的损失值标量、直方图、图像信息记录到日志文件中,通过可视化界面解析以供用户查看。\n",
"\n", "\n",
"整体流程:\n", "接下来是本次流程的体验过程。\n",
"\n",
"## 整体流程\n",
"\n", "\n",
"1. 下载MNIST数据集。\n", "1. 下载MNIST数据集。\n",
"\n", "\n",
"2. 原始数据预处理。\n", "2. 原始数据预处理。\n",
"\n", "\n",
"3. 初始化`lenet`网络。\n", "3. 初始化`LeNet`网络。\n",
"\n",
"4. 训练网络,使用`SummaryCollector`记录图像信息、损失值标量、权重梯度等参数,同时启动MindInsight服务,实时查 看损失值、参数直方图和输入图像的变化。\n",
"\n", "\n",
"4. 执行主程序,使用`SummaryCollector`记录图像信息、损失值标量、权重梯度等参数,启动MindInsight服务。\n", "5. 完成训练后,查看MindInsight看板中记录到的损失值标量、直方图、图像信息及标量对比信息。\n",
"\n", "\n",
"5. 在MindInsight可视化面板中查看结果。" "6. 分别单独记录损失值标量、直方图、图像信息,查看展示结果,关闭MindInsight服务。"
] ]
}, },
{ {
...@@ -37,7 +41,7 @@ ...@@ -37,7 +41,7 @@
"\n", "\n",
"1. 判断是否存在MNIST数据集目录,不存在则创建目录,存在则跳至[**数据预处理**](#数据预处理)。\n", "1. 判断是否存在MNIST数据集目录,不存在则创建目录,存在则跳至[**数据预处理**](#数据预处理)。\n",
"\n", "\n",
"2. 判断是否存在MNIST数据集,不存在则下载MNIST数据集,存在则跳至[**数据预处理**](#数据预处理)。\n" "2. 判断是否存在MNIST数据集,不存在则下载MNIST数据集,存在则跳至[**数据预处理**](#数据预处理)。"
] ]
}, },
{ {
...@@ -51,10 +55,12 @@ ...@@ -51,10 +55,12 @@
"from urllib.parse import urlparse\n", "from urllib.parse import urlparse\n",
"import gzip\n", "import gzip\n",
"\n", "\n",
"def unzipfile(gzip_path):\n", "def unzip_file(gzip_path):\n",
" \"\"\"unzip dataset file\n", " \"\"\"\n",
" unzip dataset file\n",
" \n",
" Args:\n", " Args:\n",
" gzip_path: dataset file path\n", " gzip_path: Dataset file path\n",
" \"\"\"\n", " \"\"\"\n",
" open_file = open(gzip_path.replace('.gz',''), 'wb')\n", " open_file = open(gzip_path.replace('.gz',''), 'wb')\n",
" gz_file = gzip.GzipFile(gzip_path)\n", " gz_file = gzip.GzipFile(gzip_path)\n",
...@@ -80,7 +86,7 @@ ...@@ -80,7 +86,7 @@
" file_name = os.path.join(train_path,url_parse.path.split('/')[-1])\n", " file_name = os.path.join(train_path,url_parse.path.split('/')[-1])\n",
" if not os.path.exists(file_name.replace('.gz','')):\n", " if not os.path.exists(file_name.replace('.gz','')):\n",
" file = urllib.request.urlretrieve(url, file_name)\n", " file = urllib.request.urlretrieve(url, file_name)\n",
" unzipfile(file_name)\n", " unzip_file(file_name)\n",
" os.remove(file_name)\n", " os.remove(file_name)\n",
" for url in test_url:\n", " for url in test_url:\n",
" url_parse = urlparse(url)\n", " url_parse = urlparse(url)\n",
...@@ -88,7 +94,7 @@ ...@@ -88,7 +94,7 @@
" file_name = os.path.join(test_path,url_parse.path.split('/')[-1])\n", " file_name = os.path.join(test_path,url_parse.path.split('/')[-1])\n",
" if not os.path.exists(file_name.replace('.gz','')):\n", " if not os.path.exists(file_name.replace('.gz','')):\n",
" file = urllib.request.urlretrieve(url, file_name)\n", " file = urllib.request.urlretrieve(url, file_name)\n",
" unzipfile(file_name)\n", " unzip_file(file_name)\n",
" os.remove(file_name)" " os.remove(file_name)"
] ]
}, },
...@@ -233,11 +239,11 @@ ...@@ -233,11 +239,11 @@
"source": [ "source": [
"# 记录标量、直方图、图像\n", "# 记录标量、直方图、图像\n",
"\n", "\n",
"在主程序中用`SummaryCollector`来记录标量、直方图、图像信息。\n", "在主程序中使用`SummaryCollector`来记录标量、直方图、图像信息。\n",
"\n", "\n",
"## 运行主程序\n", "## 运行主程序\n",
"\n", "\n",
"在MindSpore中通过`Callback`机制提供支持快速简易地收集损失值、参数权重、梯度等信息的`Callback`, 叫做`SummaryCollector`。详细的用法可以参考API文档中`mindspore.train.callback.SummaryCollector`。 \n", "在MindSpore中通过`Callback`机制提供支持快速简易地收集损失值、参数权重、梯度等信息的`Callback`, 叫做`SummaryCollector`。详细的用法可以参考API文档中`mindspore.train.callback.SummaryCollector`。 \n",
"\n", "\n",
"1. 为了记录损失值标量、直方图、图像信息,在主程序代码中需要在`specified`参数中指定需要记录的信息。\n", "1. 为了记录损失值标量、直方图、图像信息,在主程序代码中需要在`specified`参数中指定需要记录的信息。\n",
"\n", "\n",
...@@ -252,7 +258,7 @@ ...@@ -252,7 +258,7 @@
"\n", "\n",
"2. 实例化`SummaryCollector`,并将其应用到`model.train`或者`model.eval`中。\n", "2. 实例化`SummaryCollector`,并将其应用到`model.train`或者`model.eval`中。\n",
"\n", "\n",
"程序运行过程中将启动MindInsight服务并自动遍历读取当前notebook目录下`summary_dir`子目录下所有日志文件、解析进行可视化展示。" "&nbsp; 程序运行过程中将在本地`8080`端口自动启动MindInsight服务并自动遍历读取当前notebook目录下`summary_dir`子目录下所有日志文件、解析进行可视化展示。"
] ]
}, },
{ {
...@@ -308,17 +314,17 @@ ...@@ -308,17 +314,17 @@
"\n", "\n",
"![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/mindinsight_panel.png)\n", "![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/mindinsight_panel.png)\n",
"\n", "\n",
"在上图所示面板中可以看到`summary_01`日志文件目录,点击训练看板进入到下图所示的训练数据展示面板,该面板展示了标量数据、直方图和图像信息,并随着训练、测试的进行实时刷新数据,实时显示训练过程参数的变化情况。\n", "在上图所示面板中可以看到`summary_01`日志文件目录,点击**训练看板**进入到下图所示的训练数据展示面板,该面板展示了标量数据、直方图和图像信息,并随着训练、测试的进行实时刷新数据,实时显示训练过程参数的变化情况。\n",
"\n", "\n",
"![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/mindinsight_panel2.png)\n", "![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/mindinsight_panel2.png)\n",
"\n", "\n",
"## 标量可视化\n", "## 标量可视化\n",
"\n", "\n",
"标量可视化用于展示训练过程中标量的变化趋势情况,点击打开标量信息展示面板,该面板记录了迭代计算过程中的学习率(下图左侧所示)和损失值(下图右侧所示)标量信息。\n", "标量可视化用于展示训练过程中标量的变化趋势情况,点击打开标量信息展示面板,该面板记录了迭代计算过程中的损失值标量信息。\n",
"\n", "\n",
"![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/scalar_panel.png)\n", "![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/scalar_panel.png)\n",
"\n", "\n",
"如下图的loss值标量可视化信息——标量趋势图。\n", "如下图的loss值标量趋势图。\n",
"\n", "\n",
"![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/scalar.png)\n", "![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/scalar.png)\n",
"\n", "\n",
...@@ -330,7 +336,7 @@ ...@@ -330,7 +336,7 @@
"\n", "\n",
"- 切换Y轴比例是指可以将Y轴坐标进行对数转换。\n", "- 切换Y轴比例是指可以将Y轴坐标进行对数转换。\n",
"\n", "\n",
"- 开启/关闭框选是指可以框选图中部分区域,并放大查看该区域, 可以在已放大的图形上叠加框选。\n", "- 开启/关闭框选是指可以框选图中部分区域,并放大查看该区域,可以在已放大的图形上叠加框选。\n",
"\n", "\n",
"- 分步回退是指对同一个区域连续框选并放大查看时,可以逐步撤销操作。\n", "- 分步回退是指对同一个区域连续框选并放大查看时,可以逐步撤销操作。\n",
"\n", "\n",
...@@ -360,6 +366,10 @@ ...@@ -360,6 +366,10 @@
"\n", "\n",
"![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/histogram.png)\n", "![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/histogram.png)\n",
"\n", "\n",
"下图为直方图功能区。\n",
"\n",
"![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/histogram_func.png)\n",
"\n",
"上图展示直方图的功能区,包含以下内容:\n", "上图展示直方图的功能区,包含以下内容:\n",
"\n", "\n",
"- 标签选择:提供了对所有标签进行多项选择的功能,用户可以通过勾选所需的标签,查看对应的直方图。\n", "- 标签选择:提供了对所有标签进行多项选择的功能,用户可以通过勾选所需的标签,查看对应的直方图。\n",
...@@ -372,11 +382,9 @@ ...@@ -372,11 +382,9 @@
"\n", "\n",
"图像可视化用于展示用户所指定的图片。点击图像展示面板,展示了每个step进行处理的图像信息。\n", "图像可视化用于展示用户所指定的图片。点击图像展示面板,展示了每个step进行处理的图像信息。\n",
"\n", "\n",
"![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/image_panel.png)\n",
"\n",
"下图为展示`summary_01`记录的图像信息。\n", "下图为展示`summary_01`记录的图像信息。\n",
"\n", "\n",
"![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/image_vi.png)\n", "![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/image_panel.png)\n",
"\n", "\n",
"通过滑动上图中的\"步骤\"滑条,查看不同步骤的图片。\n", "通过滑动上图中的\"步骤\"滑条,查看不同步骤的图片。\n",
"\n", "\n",
...@@ -397,7 +405,7 @@ ...@@ -397,7 +405,7 @@
"source": [ "source": [
"## 对比看板\n", "## 对比看板\n",
"\n", "\n",
"对比看板可视用于多训练之间的标量数据对比,为了展示对比看板,执行以下代码,在可视化面板中可以得到`summary_02`日志记录信息。" "对比看板可视用于多训练之间的标量数据对比,为了展示对比看板,执行以下代码,在可视化面板中可以得到`summary_02`日志记录信息。"
] ]
}, },
{ {
...@@ -445,29 +453,17 @@ ...@@ -445,29 +453,17 @@
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {}, "metadata": {},
"source": [ "source": [
"打开对比看板,可以得到`summary_01`和`summary_02`标量对比信息。\n", "点击MindInsight看板中的**对比看板**,打开对比看板,可以得到`summary_01`和`summary_02`标量对比信息。\n",
"\n", "\n",
"![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/multi_scalars.png)\n", "![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/multi_scalars.png)\n",
"\n", "\n",
"上图展示了多个训练之间的标量曲线对比效果,横坐标是训练步骤,纵坐标是标量值。\n", "上图展示了多次训练之间的标量曲线对比效果,横坐标是训练步骤,纵坐标是标量值。\n",
"\n",
"图中右上角有几个按钮功能,从左到右功能分别是全屏展示,切换Y轴比例,开启/关闭框选,分步回退和还原图形。\n",
"\n",
"- 全屏展示即全屏展示该标量曲线,再点击一次即可恢复。\n",
"\n",
"- 切换Y轴比例是指可以将Y轴坐标进行对数转换。\n",
"\n",
"- 开启/关闭框选是指可以框选图中部分区域,并放大查看该区域, 可以在已放大的图形上叠加框选。\n",
"\n",
"- 分步回退是指对同一个区域连续框选并放大查看时,可以逐步撤销操作。\n",
"\n",
"- 还原图形是指进行了多次框选后,点击此按钮可以将图还原回原始状态。\n",
"\n", "\n",
"![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/multi_scalars_select.png)\n", "![](https://gitee.com/mindspore/docs/raw/master/tutorials/notebook/mindinsight/images/multi_scalars_select.png)\n",
"\n", "\n",
"上图展示的对比看板可视的功能区,提供了根据选择不同训练或标签,水平轴的不同维度和平滑度来进行标量对比的功能。\n", "上图展示的对比看板可视的功能区,提供了根据选择不同训练或标签,水平轴的不同维度和平滑度来进行标量对比的功能。\n",
"\n", "\n",
"- 训练: 提供了对所有训练进行多项选择的功能,用户可以通过勾选或关键字筛选所需的训练。\n", "- 训练提供了对所有训练进行多项选择的功能,用户可以通过勾选或关键字筛选所需的训练。\n",
"\n", "\n",
"- 标签:提供了对所有标签进行多项选择的功能,用户可以通过勾选所需的标签,查看对应的标量信息。\n", "- 标签:提供了对所有标签进行多项选择的功能,用户可以通过勾选所需的标签,查看对应的标量信息。\n",
"\n", "\n",
...@@ -484,7 +480,7 @@ ...@@ -484,7 +480,7 @@
"\n", "\n",
"以上流程为整体展示Summary算子能记录到的所有数据,也可以单独记录关心的数据,以降低性能开销和日志文件大小。\n", "以上流程为整体展示Summary算子能记录到的所有数据,也可以单独记录关心的数据,以降低性能开销和日志文件大小。\n",
"\n", "\n",
"> 为了展示运行的效果,进行以下每个步骤之前先删除当前notebook根目录下的`summary_dir/summary_02`目录,配置完`specified`参数后执行[**对比看板**](#对比看板)中的代码。\n", "此处利用[**对比看板**](#对比看板)中的代码,为了排除前次训练对MindInsight展示结果的影响,在进行以下每个步骤之前先删除当前notebook根目录下的`summary_dir/summary_02`目录,配置完`specified`参数后执行[**对比看板**](#对比看板)中的代码,在MindInsight看板中查看结果。\n",
"\n", "\n",
"## 单独记录损失值标量\n", "## 单独记录损失值标量\n",
"\n", "\n",
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
<!-- /TOC --> <!-- /TOC -->
<a href="https://gitee.com/mindspore/docs/blob/master/tutorials/source_zh_cn/advanced_use/dashboard_and_lineage.md" target="_blank"><img src="../_static/logo_source.png"></a>&nbsp;&nbsp; <a href="https://gitee.com/mindspore/docs/blob/master/tutorials/source_zh_cn/advanced_use/dashboard_and_lineage.md" target="_blank"><img src="../_static/logo_source.png"></a>&nbsp;&nbsp;
<a href="https://gitee.com/mindspore/docs/tree/master/tutorials/notebook/mindinsight" target="_blank"><img src="../_static/logo_source.png"></a> <a href="https://gitee.com/mindspore/docs/tree/master/tutorials/notebook/mindinsight" target="_blank"><img src="../_static/logo_notebook.png"></a>
## 概述 ## 概述
训练过程中的标量、图像、计算图以及模型超参等信息记录到文件中,通过可视化界面供用户查看。 训练过程中的标量、图像、计算图以及模型超参等信息记录到文件中,通过可视化界面供用户查看。
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册