Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions python/paddle/metric/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

from ..fluid.data_feeder import check_variable_and_dtype
from ..fluid.layer_helper import LayerHelper
from ..fluid.layers.nn import topk
from ..fluid.framework import core, _varbase_creator, in_dygraph_mode
import paddle
from paddle import _C_ops
Expand Down Expand Up @@ -798,15 +797,15 @@ def accuracy(input, label, k=1, correct=None, total=None, name=None):
if total is None:
total = _varbase_creator(dtype="int32")

topk_out, topk_indices = topk(input, k=k)
topk_out, topk_indices = paddle.topk(input, k=k)
_acc, _, _ = _C_ops.accuracy(topk_out, topk_indices, label, correct,
total)
return _acc

helper = LayerHelper("accuracy", **locals())
check_variable_and_dtype(input, 'input', ['float16', 'float32', 'float64'],
'accuracy')
topk_out, topk_indices = topk(input, k=k)
topk_out, topk_indices = paddle.topk(input, k=k)
acc_out = helper.create_variable_for_type_inference(dtype="float32")
if correct is None:
correct = helper.create_variable_for_type_inference(dtype="int32")
Expand Down