From 2c3e2eae6dff6edf70c658c8707295670838c05e Mon Sep 17 00:00:00 2001 From: hedaoyuan Date: Tue, 18 Apr 2017 16:34:46 +0800 Subject: [PATCH] Add plot --- 05.understand_sentiment/README.md | 13 + 05.understand_sentiment/index.html | 843 +++++++++++++++-------------- 2 files changed, 441 insertions(+), 415 deletions(-) diff --git a/05.understand_sentiment/README.md b/05.understand_sentiment/README.md index 891461e..584f44f 100644 --- a/05.understand_sentiment/README.md +++ b/05.understand_sentiment/README.md @@ -310,6 +310,19 @@ Paddle中提供了一系列优化算法的API,这里使用Adam优化算法。 print "\nTest with Pass %d, %s" % (event.pass_id, result.metrics) ``` 可以通过给train函数传递一个`event_handler`来获取每个batch和每个pass结束的状态。比如构造如下一个`event_handler`可以在每100个batch结束后输出cost和error;在每个pass结束后调用`trainer.test`计算一遍测试集并获得当前模型在测试集上的error。 +```python + from paddle.v2.plot import Ploter + + train_title = "Train cost" + cost_ploter = Ploter(train_title) + step = 0 + def event_handler_plot(event): + global step + if isinstance(event, paddle.event.EndIteration): + cost_ploter.append(train_title, step, event.cost) + cost_ploter.plot() + step += 1 +``` ```python # create trainer trainer = paddle.trainer.SGD(cost=cost, diff --git a/05.understand_sentiment/index.html b/05.understand_sentiment/index.html index b55e1f7..67c8d84 100644 --- a/05.understand_sentiment/index.html +++ b/05.understand_sentiment/index.html @@ -1,415 +1,428 @@ - - - - - - - - - - - - - - - - - -
-
- - - - - - - + + + + + + + + + + + + + + + + + +
+
+ + + + + + + -- GitLab