[Docathon][Add API Legend No.15]+Add api_legend image #6990
+0
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
.. _cn_api_paddle_atleast_1d:
atleast_1d
.. py:function:: paddle.atleast_1d(*inputs, name=None)
该函数将输入转换为张量并确保返回的张量至少为 1 维。如果输入是标量,则会被转换为 1 维张量;如果输入是 1 维或更高维的张量,则会被保留原样。此函数非常有用,特别是在需要确保输入的维度符合要求时。
下面的图例展示了 paddle.atleast_1d 函数如何处理不同维度的输入,以确保输出至少为一维。
.. figure:: ../../images/api_legend/atleast_1d.png
:width: 500
:alt: Illustration of paddle.atleast_1d Function Operations
:align: center
参数 ::::::::::::
inputs (Tensor|list(Tensor)) - 一个或多个输入的 Tensor,支持的输入数据类型包括:float16、float32、float64、int16、int32、int64、int8、uint8、complex64、complex128、bfloat16 或 bool。
name (str,可选) - 用于指定操作名称,具体用法请参见 :ref:api_guide_Name,通常无需设置,默认值为 None。
返回 ::::::::::::
返回值是一个 Tensor 或一个包含 Tensor 的 list。如果只有一个输入,则返回一个 Tensor;如果有多个输入,则返回一个由 Tensor 组成的 list。
代码示例 ::::::::::::
COPY-FROM: paddle.atleast_1d