提交 ef2859af 编写于 作者: G Genieliu 提交者: Cheerego

fix metric example (#741)

pass is the key word in python
acc.update should be in the for loop
上级 fac64b52
......@@ -22,15 +22,15 @@ Fluid中包含了常用分类指标,例如Precision, Recall, Accuracy等,更
.. code-block:: python
>>> import paddle.fluid as fluid
>>> labels = fluid.layers.data(name="data", shape=[1], dtype="int32")
>>> label = fluid.layers.data(name="label", shape=[1], dtype="int32")
>>> data = fluid.layers.data(name="data", shape=[32, 32], dtype="int32")
>>> pred = fluid.layers.fc(input=data, size=1000, act="tanh")
>>> acc = fluid.metrics.Precision()
>>> for pass in range(PASSES):
>>> for pass_iter in range(PASSES):
>>> acc.reset()
>>> for data in train_reader():
>>> loss, preds, labels = exe.run(fetch_list=[cost, preds, labels])
>>> acc.update(preds=preds, labels=labels)
>>> loss, preds, labels = exe.run(fetch_list=[cost, pred, label])
>>> acc.update(preds=preds, labels=labels)
>>> numpy_acc = acc.eval()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册