From 480375fbe3a9dff3b9225f337cc13a7d2a305ad4 Mon Sep 17 00:00:00 2001 From: Megvii Engine Team Date: Sat, 10 Oct 2020 19:22:01 +0800 Subject: [PATCH] feat(mge): rename accuracy -> topk_accuracy GitOrigin-RevId: b6ae007231e6bcb93918b6bdfc6165a67f5b1efc --- imperative/python/megengine/functional/__init__.py | 2 +- imperative/python/megengine/functional/utils.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/imperative/python/megengine/functional/__init__.py b/imperative/python/megengine/functional/__init__.py index 56f26e6aa..4d70c8a68 100644 --- a/imperative/python/megengine/functional/__init__.py +++ b/imperative/python/megengine/functional/__init__.py @@ -13,7 +13,7 @@ from .math import * from .nn import * from .quantized import conv_bias_activation from .tensor import * -from .utils import accuracy, copy +from .utils import * from . import distributed # isort:skip diff --git a/imperative/python/megengine/functional/utils.py b/imperative/python/megengine/functional/utils.py index d518b69f2..fa38e8b1f 100644 --- a/imperative/python/megengine/functional/utils.py +++ b/imperative/python/megengine/functional/utils.py @@ -18,8 +18,13 @@ from ..core.tensor.core import apply from .math import topk as _topk from .tensor import broadcast_to, transpose +__all__ = [ + "topk_accuracy", + "copy", +] -def accuracy( + +def topk_accuracy( logits: Tensor, target: Tensor, topk: Union[int, Iterable[int]] = 1 ) -> Union[Tensor, Iterable[Tensor]]: r""" @@ -41,7 +46,7 @@ def accuracy( logits = tensor(np.arange(80, dtype=np.int32).reshape(8,10)) target = tensor(np.arange(8, dtype=np.int32)) - top1, top5 = F.accuracy(logits, target, (1, 5)) + top1, top5 = F.topk_accuracy(logits, target, (1, 5)) print(top1.numpy(), top5.numpy()) Outputs: -- GitLab