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