diff --git a/imperative/python/megengine/functional/__init__.py b/imperative/python/megengine/functional/__init__.py index 56f26e6aa9abc0fa6678058a6383a421e951d448..4d70c8a6855f398672d853e1346c90be0882aeb5 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 d518b69f21b8d6cfddaa10d521bbc89b980e9987..fa38e8b1fc7ddd24db0cdb77007b9548e2476529 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: