提交 288484b1 编写于 作者: L liaogang

add htmls

上级 0a404b9c
......@@ -67,6 +67,7 @@ RUN ${update_mirror_cmd}
apt-get -y install gcc && \
apt-get -y clean && \
localedef -f UTF-8 -i en_US en_US.UTF-8 && \
pip install --upgrade pip && \
pip install -U pillow matplotlib jupyter numpy requests scipy
#convert md to ipynb
......
......@@ -162,6 +162,23 @@ feeding={'x': 0, 'y': 1}
Moreover, an event handler is provided to print the training progress:
```python
lists = []
def event_handler(event):
if isinstance(event, paddle.event.EndIteration):
if event.batch_id % 100 == 0:
print "Pass %d, Batch %d, Cost %f, %s" % (
event.pass_id, event.batch_id, event.cost, event.metrics)
if isinstance(event, paddle.event.EndPass):
result = trainer.test(reader=paddle.batch(
paddle.dataset.mnist.test(), batch_size=128))
print "Test with Pass %d, Cost %f, %s\n" % (
event.pass_id, result.cost, result.metrics)
lists.append((event.pass_id, result.cost,
result.metrics['classification_error_evaluator']))
```
```python
# event_handler to print training and testing info
from paddle.v2.plot import Ploter
......@@ -172,7 +189,7 @@ plot_cost = Ploter(train_title, test_title)
step = 0
def event_handler(event):
def event_handler_plot(event):
global step
if isinstance(event, paddle.event.EndIteration):
if step % 10 == 0: # every 10 batches, record a train cost
......@@ -200,7 +217,7 @@ trainer.train(
uci_housing.train(), buf_size=500),
batch_size=2),
feeding=feeding,
event_handler=event_handler,
event_handler=event_handler_plot,
num_passes=30)
```
......
......@@ -157,6 +157,23 @@ feeding={'x': 0, 'y': 1}
此外,我们还可以提供一个 event handler,来打印训练的进度:
```python
lists = []
def event_handler(event):
if isinstance(event, paddle.event.EndIteration):
if event.batch_id % 100 == 0:
print "Pass %d, Batch %d, Cost %f, %s" % (
event.pass_id, event.batch_id, event.cost, event.metrics)
if isinstance(event, paddle.event.EndPass):
result = trainer.test(reader=paddle.batch(
paddle.dataset.mnist.test(), batch_size=128))
print "Test with Pass %d, Cost %f, %s\n" % (
event.pass_id, result.cost, result.metrics)
lists.append((event.pass_id, result.cost,
result.metrics['classification_error_evaluator']))
```
```python
# event_handler to print training and testing info
from paddle.v2.plot import Ploter
......@@ -167,7 +184,7 @@ cost_ploter = Ploter(train_title, test_title)
step = 0
def event_handler(event):
def event_handler_plot(event):
global step
if isinstance(event, paddle.event.EndIteration):
if step % 10 == 0: # every 10 batches, record a train cost
......@@ -195,7 +212,7 @@ trainer.train(
uci_housing.train(), buf_size=500),
batch_size=2),
feeding=feeding,
event_handler=event_handler,
event_handler=event_handler_plot,
num_passes=30)
```
......
......@@ -204,6 +204,23 @@ feeding={'x': 0, 'y': 1}
Moreover, an event handler is provided to print the training progress:
```python
lists = []
def event_handler(event):
if isinstance(event, paddle.event.EndIteration):
if event.batch_id % 100 == 0:
print "Pass %d, Batch %d, Cost %f, %s" % (
event.pass_id, event.batch_id, event.cost, event.metrics)
if isinstance(event, paddle.event.EndPass):
result = trainer.test(reader=paddle.batch(
paddle.dataset.mnist.test(), batch_size=128))
print "Test with Pass %d, Cost %f, %s\n" % (
event.pass_id, result.cost, result.metrics)
lists.append((event.pass_id, result.cost,
result.metrics['classification_error_evaluator']))
```
```python
# event_handler to print training and testing info
from paddle.v2.plot import Ploter
......@@ -214,7 +231,7 @@ plot_cost = Ploter(train_title, test_title)
step = 0
def event_handler(event):
def event_handler_plot(event):
global step
if isinstance(event, paddle.event.EndIteration):
if step % 10 == 0: # every 10 batches, record a train cost
......@@ -242,7 +259,7 @@ trainer.train(
uci_housing.train(), buf_size=500),
batch_size=2),
feeding=feeding,
event_handler=event_handler,
event_handler=event_handler_plot,
num_passes=30)
```
......
......@@ -199,6 +199,23 @@ feeding={'x': 0, 'y': 1}
此外,我们还可以提供一个 event handler,来打印训练的进度:
```python
lists = []
def event_handler(event):
if isinstance(event, paddle.event.EndIteration):
if event.batch_id % 100 == 0:
print "Pass %d, Batch %d, Cost %f, %s" % (
event.pass_id, event.batch_id, event.cost, event.metrics)
if isinstance(event, paddle.event.EndPass):
result = trainer.test(reader=paddle.batch(
paddle.dataset.mnist.test(), batch_size=128))
print "Test with Pass %d, Cost %f, %s\n" % (
event.pass_id, result.cost, result.metrics)
lists.append((event.pass_id, result.cost,
result.metrics['classification_error_evaluator']))
```
```python
# event_handler to print training and testing info
from paddle.v2.plot import Ploter
......@@ -209,7 +226,7 @@ cost_ploter = Ploter(train_title, test_title)
step = 0
def event_handler(event):
def event_handler_plot(event):
global step
if isinstance(event, paddle.event.EndIteration):
if step % 10 == 0: # every 10 batches, record a train cost
......@@ -237,7 +254,7 @@ trainer.train(
uci_housing.train(), buf_size=500),
batch_size=2),
feeding=feeding,
event_handler=event_handler,
event_handler=event_handler_plot,
num_passes=30)
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册