Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions docs/api/paddle/Overview_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ tensor 数学操作
" :ref:`paddle.i1e <cn_api_paddle_i1e>` ", "对输入 Tensor 每个元素计算第一类指数缩放的一阶修正贝塞尔函数"
" :ref:`paddle.polygamma <cn_api_paddle_polygamma>` ", "对输入 Tensor 每个元素计算多伽马函数"
" :ref:`paddle.hypot <cn_api_paddle_hypot>` ", "对输入 直角三角形的直角边 Tensor x, y, 计算其斜边"
" :ref:`paddle.combinations <cn_api_paddle_combinations>` ", "对输入 Tensor 计算长度为 r 的情况下的所有组合"
.. _tensor_math_inplace:

tensor 数学操作原位(inplace)版本
Expand Down
1 change: 1 addition & 0 deletions docs/api/paddle/Tensor/Overview_en.rst
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,4 @@ Methods
hypot
hypot_
diagonal_scatter
combinations
25 changes: 25 additions & 0 deletions docs/api/paddle/combinations_cn.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.. _cn_api_paddle_combinations:

combinations
-------------------------------

.. py:function:: paddle.combinations(x, r=2, with_replacement=False, name=None)

对输入 Tensor 计算长度为 r 的情况下的所有组合,当 `with_replacement` 设为 False,可类比 python 内置 API `itertools.combinations` 。
当 `with_replacement` 设为 True,可类比 python 内置 API `itertools.combinations_with_replacement(with_replacement=Ture)`。

参数
::::::::::
- **x** (Tensor) - 输入 1-D Tensor ,它的数据类型可以是 float16,float32,float64,int32,int64。
- **r** (int,可选) - 组合的数长度,默认值为 2。
- **with_replacement** (bool,可选) - 是否允许组合数中出现重复值,默认不允许,默认值为 False。
- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为 None。

返回
::::::::::
- ``out`` (Tensor):由组合数拼接而成的 Tensor ,和输入 x 类型相同。

代码示例
::::::::::

COPY-FROM: paddle.combinations