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

【Hackathon 5th No.14】Add combinations API to Paddle #6287

Merged
merged 2 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -154,6 +154,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 @@ -277,3 +277,4 @@ Methods
vander
hypot
hypot_
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` 设为True时可类比python中API `itertools.combinations` 。
而当 `with_replacement` 设为True则可类比API `itertools.combinations_with_replacement` 中参数 `with_replacement` 设为True。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 是不是写错了?应该是一个为 False 一个为 True 吧。另外语句尽量通顺一些
  2. 中英文之间加空格


参数
::::::::::
- **x** (Tensor) - 输入 1-D Tensor,它的数据类型可以是 float16,float32,float64,int32,int64。
- **r** (int,可选) - 组合的数长度,默认值为 2。
- **with_replacement** (bool,可选) - 是否运行组合数中出现重复值,默认值为 False。
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

写明默认值为 false 代表的含义

- **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为 None。

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

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

COPY-FROM: paddle.combinations