Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
FluidDoc
提交
45a48e0c
F
FluidDoc
项目概览
PaddlePaddle
/
FluidDoc
通知
10
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
23
列表
看板
标记
里程碑
合并请求
111
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
F
FluidDoc
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
23
Issue
23
列表
看板
标记
里程碑
合并请求
111
合并请求
111
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
45a48e0c
编写于
6月 09, 2020
作者:
Q
Qi Li
提交者:
GitHub
6月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add new operator api: paddle.histc(input, bins=100, min=0, max=0) (#2147)
Add new operator api: paddle.histc(input, bins=100, min=0, max=0)
上级
5df75345
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
55 addition
and
1 deletion
+55
-1
doc/fluid/api/gen_doc.sh
doc/fluid/api/gen_doc.sh
+1
-1
doc/fluid/api_cn/tensor_cn.rst
doc/fluid/api_cn/tensor_cn.rst
+1
-0
doc/fluid/api_cn/tensor_cn/histogram_cn.rst
doc/fluid/api_cn/tensor_cn/histogram_cn.rst
+53
-0
未找到文件。
doc/fluid/api/gen_doc.sh
浏览文件 @
45a48e0c
...
...
@@ -10,7 +10,7 @@ python gen_doc.py --module_name "" --module_prefix "" --output fluid --output_na
python gen_module_index.py fluid fluid
# tensor
for
module
in
math random
stat
for
module
in
math random
stat
linalg
do
python gen_doc.py
--module_name
${
module
}
--module_prefix
${
module
}
--output
${
module
}
--output_name
tensor
--to_multiple_files
True
--output_dir
tensor
python gen_module_index.py tensor.
${
module
}
${
module
}
...
...
doc/fluid/api_cn/tensor_cn.rst
浏览文件 @
45a48e0c
...
...
@@ -65,6 +65,7 @@ paddle.tensor
tensor_cn/greater_than_cn.rst
tensor_cn/has_inf_cn.rst
tensor_cn/has_nan_cn.rst
tensor_cn/histogram_cn.rst
tensor_cn/increment_cn.rst
tensor_cn/index_sample_cn.rst
tensor_cn/index_select_cn.rst
...
...
doc/fluid/api_cn/tensor_cn/histogram_cn.rst
0 → 100644
浏览文件 @
45a48e0c
.. _cn_api_tensor_histogram:
histogram
-------------------------------
.. py:function:: paddle.histogram(input, bins=100, min=0, max=0):
计算输入张量的直方图。以min和max为range边界,将其均分成bins个直条,然后将排序好的数据划分到各个直条(bins)中。如果min和max都为0, 则利用数据中的最大最小值作为边界。
参数:
- **input** (Variable) - 输入Tensor。维度为多维,数据类型为int32, int64, float32或float64。
- **bins** (int) - 直方图 bins(直条)的个数,默认为100。
- **min** (int) - range的下边界(包含),默认为0。
- **max** (int) - range的上边界(包含),默认为0。
返回:直方图。
返回类型:Variable,数据为int64类型,维度为(nbins,)。
抛出异常:
- ``ValueError`` - 当输入 ``bin``, ``min``, ``max``不合法时。
**代码示例1**:
.. code-block:: python
import paddle
import numpy as np
startup_program = paddle.Program()
train_program = paddle.Program()
with paddle.program_guard(train_program, startup_program):
inputs = paddle.data(name='input', dtype='int32', shape=[2,3])
output = paddle.histogram(inputs, bins=5, min=1, max=5)
place = paddle.CPUPlace()
exe = paddle.Executor(place)
exe.run(startup_program)
img = np.array([[2, 4, 2], [2, 5, 4]]).astype(np.int32)
res = exe.run(train_program,
feed={'input': img},
fetch_list=[output])
print(np.array(res[0])) # [0, 3, 0, 2, 1]
**代码示例2**:
.. code-block:: python
import paddle
import numpy as np
with paddle.imperative.guard(paddle.CPUPlace()):
inputs_np = np.array([0.5, 1.5, 2.5]).astype(np.float)
inputs = paddle.imperative.to_variable(inputs_np)
result = paddle.histogram(inputs, bins=5, min=1, max=5)
print(result) # [1, 1, 0, 0, 0]
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录