From bebe9e0e9c445948183924a9d4d5b486a1c09c3c Mon Sep 17 00:00:00 2001 From: wenkai Date: Mon, 27 Apr 2020 19:33:12 +0800 Subject: [PATCH] update histogram summary doc, add tips about histogram summary performance. --- .../source_en/advanced_use/visualization_tutorials.md | 10 ++++++---- .../advanced_use/visualization_tutorials.md | 8 +++++--- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tutorials/source_en/advanced_use/visualization_tutorials.md b/tutorials/source_en/advanced_use/visualization_tutorials.md index a50b74c14e..5f2cb6823a 100644 --- a/tutorials/source_en/advanced_use/visualization_tutorials.md +++ b/tutorials/source_en/advanced_use/visualization_tutorials.md @@ -80,7 +80,6 @@ class MyOptimizer(Optimizer): # Initialize ScalarSummary self.sm_scalar = P.ScalarSummary() self.histogram_summary = P.HistogramSummary() - self.param_count = len(self.parameters) self.weight_names = [param.name for param in self.parameters] def construct(self, grads): @@ -89,8 +88,9 @@ class MyOptimizer(Optimizer): self.sm_scalar("learning_rate", learning_rate) # Record weight - for i in range(self.param_count): - self.histogram_summary(self.weight_names[i], self.paramters[i]) + self.histogram_summary(self.weight_names[0], self.paramters[0]) + # Record gradient + self.histogram_summary(self.weight_names[0] + ".gradient", grads[0]) ...... @@ -169,6 +169,8 @@ Use the `save_graphs` option of `context` to record the computational graph afte > Currently MindSpore supports recording computational graph after operator fusion for Ascend 910 AI processor only. +> It's recommended that you reduce calls to `HistogramSummary` under 10 times per batch. The more you call `HistogramSummary`, the more performance overhead. + ## MindInsight Commands ### View the command help information. @@ -388,4 +390,4 @@ Figure 16 shows the function area of the parameter distribution histogram, inclu - Tag selection: Select the required tags to view the corresponding histogram. - Vertical axis: Select any of `Step`, `Relative time`, and `Absolute time` as the data displayed on the vertical axis of the histogram. -- Angle of view: Select either `Front` or `Top`. `Front` view refers to viewing the histogram from the front view. In this case, data between different steps is overlapped. `Top` view refers to viewing the histogram at an angle of 45 degrees. In this case, data between different steps can be presented. \ No newline at end of file +- Angle of view: Select either `Front` or `Top`. `Front` view refers to viewing the histogram from the front view. In this case, data between different steps is overlapped. `Top` view refers to viewing the histogram at an angle of 45 degrees. In this case, data between different steps can be presented. diff --git a/tutorials/source_zh_cn/advanced_use/visualization_tutorials.md b/tutorials/source_zh_cn/advanced_use/visualization_tutorials.md index b2f7648b53..37cbed6a2d 100644 --- a/tutorials/source_zh_cn/advanced_use/visualization_tutorials.md +++ b/tutorials/source_zh_cn/advanced_use/visualization_tutorials.md @@ -85,7 +85,6 @@ class MyOptimizer(Optimizer): # Initialize ScalarSummary self.sm_scalar = P.ScalarSummary() self.histogram_summary = P.HistogramSummary() - self.param_count = len(self.parameters) self.weight_names = [param.name for param in self.parameters] def construct(self, grads): @@ -94,8 +93,9 @@ class MyOptimizer(Optimizer): self.sm_scalar("learning_rate", learning_rate) # Record weight - for i in range(self.param_count): - self.histogram_summary(self.weight_names[i], self.paramters[i]) + self.histogram_summary(self.weight_names[0], self.paramters[0]) + # Record gradient + self.histogram_summary(self.weight_names[0] + ".gradient", grads[0]) ...... @@ -175,6 +175,8 @@ def test_summary(): > 目前MindSpore仅支持在Ascend 910 AI处理器上导出算子融合后的计算图。 +> 一个batch中,`HistogramSummary`算子的调用次数请尽量控制在10次以下,调用次数越多,性能开销越大。 + ## MindInsight相关命令 ### 查看命令帮助信息 -- Gitee