From 36868e840c582047480f4c999ddf1f5f004de678 Mon Sep 17 00:00:00 2001 From: yukavio <67678385+yukavio@users.noreply.github.com> Date: Mon, 24 Aug 2020 18:35:03 +0800 Subject: [PATCH] fix one_hot example doc test=document_fix (#26585) * fix one_hot example doc test=document_fix * fix some bug --- python/paddle/nn/functional/input.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/paddle/nn/functional/input.py b/python/paddle/nn/functional/input.py index e51da1bd744..e77bf0e3967 100644 --- a/python/paddle/nn/functional/input.py +++ b/python/paddle/nn/functional/input.py @@ -72,17 +72,17 @@ def one_hot(x, num_classes, name=None): Examples: .. code-block:: python - import paddle.fluid as fluid + import paddle # Correspond to the first example above, where label.shape is 4 and one_hot_label.shape is [4, 4]. - label = fluid.data(name="label", shape=[4, 1], dtype="int64") + label = paddle.data(name="label", shape=[4, 1], dtype="int64") # label.shape = [4] # label.data = [1, 1, 3, 0] - one_hot_label = fluid.one_hot(x=label, num_classes=4) + one_hot_label = paddle.nn.functional.one_hot(x=label, num_classes=4) # one_hot_label.shape = [4, 4] # one_hot_label.data = [[0., 1., 0., 0.], - [0., 1., 0., 0.], - [0., 0., 0., 1.], - [1., 0., 0., 0.]] + # [0., 1., 0., 0.], + # [0., 0., 0., 1.], + # [1., 0., 0., 0.]] """ if in_dygraph_mode(): -- GitLab