Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix one_hot example doc test=document_fix #26585

Merged
merged 2 commits into from
Aug 24, 2020
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
12 changes: 6 additions & 6 deletions python/paddle/nn/functional/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down