Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
马赛克医院
Paddle
提交
3eb12bd1
P
Paddle
项目概览
马赛克医院
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
3eb12bd1
编写于
4月 05, 2020
作者:
W
wangchaochaohu
提交者:
GitHub
4月 05, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refine the usage of paddle.full test=develop (#23484)
上级
eb035f24
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
19 addition
and
19 deletion
+19
-19
python/paddle/fluid/tests/unittests/test_full_op.py
python/paddle/fluid/tests/unittests/test_full_op.py
+14
-14
python/paddle/tensor/creation.py
python/paddle/tensor/creation.py
+5
-5
未找到文件。
python/paddle/fluid/tests/unittests/test_full_op.py
浏览文件 @
3eb12bd1
...
...
@@ -21,7 +21,7 @@ from op_test import OpTest
import
paddle.fluid.core
as
core
from
paddle.fluid.op
import
Operator
import
paddle.fluid
as
fluid
import
paddle
.tensor
as
tensor
import
paddle
from
paddle.fluid
import
compiler
,
Program
,
program_guard
...
...
@@ -37,35 +37,35 @@ class TestFullAPI(unittest.TestCase):
shape_tensor_int64
=
fluid
.
data
(
name
=
"shape_tensor_int64"
,
shape
=
[
2
],
dtype
=
"int64"
)
out_1
=
tensor
.
full
(
out_1
=
paddle
.
full
(
shape
=
[
1
,
2
],
dtype
=
"float32"
,
fill_value
=
1.1
,
device
=
'gpu'
)
out_2
=
tensor
.
full
(
out_2
=
paddle
.
full
(
shape
=
[
1
,
positive_2_int32
],
dtype
=
"float32"
,
fill_value
=
1.1
,
device
=
'cpu'
)
out_3
=
tensor
.
full
(
out_3
=
paddle
.
full
(
shape
=
[
1
,
positive_2_int64
],
dtype
=
"float32"
,
fill_value
=
1.1
,
device
=
'gpu'
)
out_4
=
tensor
.
full
(
out_4
=
paddle
.
full
(
shape
=
shape_tensor_int32
,
dtype
=
"float32"
,
fill_value
=
1.2
,
out
=
out_3
)
out_5
=
tensor
.
full
(
out_5
=
paddle
.
full
(
shape
=
shape_tensor_int64
,
dtype
=
"float32"
,
fill_value
=
1.1
,
device
=
'gpu'
,
stop_gradient
=
False
)
out_6
=
tensor
.
full
(
out_6
=
paddle
.
full
(
shape
=
shape_tensor_int64
,
dtype
=
np
.
float32
,
fill_value
=
1.1
)
exe
=
fluid
.
Executor
(
place
=
fluid
.
CPUPlace
())
...
...
@@ -91,10 +91,10 @@ class TestFullOpError(unittest.TestCase):
#for ci coverage
x1
=
fluid
.
layers
.
data
(
name
=
'x1'
,
shape
=
[
1
],
dtype
=
"int16"
)
self
.
assertRaises
(
ValueError
,
tensor
.
full
,
shape
=
[
1
],
fill_value
=
5
,
dtype
=
'uint4'
)
ValueError
,
paddle
.
full
,
shape
=
[
1
],
fill_value
=
5
,
dtype
=
'uint4'
)
self
.
assertRaises
(
TypeError
,
tensor
.
full
,
paddle
.
full
,
shape
=
[
1
],
fill_value
=
5
,
dtype
=
'int16'
,
...
...
@@ -105,17 +105,17 @@ class TestFullOpError(unittest.TestCase):
x2
=
fluid
.
layers
.
data
(
name
=
'x2'
,
shape
=
[
1
],
dtype
=
"int32"
)
self
.
assertRaises
(
TypeError
,
tensor
.
full
,
shape
=
[
1
],
fill_value
=
5
,
dtype
=
'uint8'
)
TypeError
,
paddle
.
full
,
shape
=
[
1
],
fill_value
=
5
,
dtype
=
'uint8'
)
# The argument shape's type of full_op must be list, tuple or Variable.
def
test_shape_type
():
tensor
.
full
(
shape
=
1
,
dtype
=
"float32"
,
fill_value
=
1
)
paddle
.
full
(
shape
=
1
,
dtype
=
"float32"
,
fill_value
=
1
)
self
.
assertRaises
(
TypeError
,
test_shape_type
)
# The argument shape's size of full_op must not be 0.
def
test_shape_size
():
tensor
.
full
(
shape
=
[],
dtype
=
"float32"
,
fill_value
=
1
)
paddle
.
full
(
shape
=
[],
dtype
=
"float32"
,
fill_value
=
1
)
self
.
assertRaises
(
AssertionError
,
test_shape_size
)
...
...
@@ -123,14 +123,14 @@ class TestFullOpError(unittest.TestCase):
def
test_shape_tensor_dtype
():
shape
=
fluid
.
data
(
name
=
"shape_tensor"
,
shape
=
[
2
],
dtype
=
"float32"
)
tensor
.
full
(
shape
=
shape
,
dtype
=
"float32"
,
fill_value
=
1
)
paddle
.
full
(
shape
=
shape
,
dtype
=
"float32"
,
fill_value
=
1
)
self
.
assertRaises
(
TypeError
,
test_shape_tensor_dtype
)
def
test_shape_tensor_list_dtype
():
shape
=
fluid
.
data
(
name
=
"shape_tensor_list"
,
shape
=
[
1
],
dtype
=
"bool"
)
tensor
.
full
(
shape
=
[
shape
,
2
],
dtype
=
"float32"
,
fill_value
=
1
)
paddle
.
full
(
shape
=
[
shape
,
2
],
dtype
=
"float32"
,
fill_value
=
1
)
self
.
assertRaises
(
TypeError
,
test_shape_tensor_list_dtype
)
...
...
python/paddle/tensor/creation.py
浏览文件 @
3eb12bd1
...
...
@@ -370,19 +370,19 @@ def full(shape,
Examples:
.. code-block:: python
import paddle
.tensor as tensor
import paddle
import paddle.fluid as fluid
data1 =
tensor
.full(shape=[2,1], full_value=0, dtype='int64') # data1=[[0],[0]]
data2 =
tensor
.full(shape=[2,1], full_value=5, dtype='int64', device='gpu') # data2=[[5],[5]]
data1 =
paddle
.full(shape=[2,1], full_value=0, dtype='int64') # data1=[[0],[0]]
data2 =
paddle
.full(shape=[2,1], full_value=5, dtype='int64', device='gpu') # data2=[[5],[5]]
# attr shape is a list which contains Variable Tensor.
positive_2 = fluid.layers.fill_constant([1], "int32", 2)
data3 =
tensor
.full(shape=[1, positive_2], dtype='float32', full_value=1.5) # data3=[1.5, 1.5]
data3 =
paddle
.full(shape=[1, positive_2], dtype='float32', full_value=1.5) # data3=[1.5, 1.5]
# attr shape is an Variable Tensor.
shape = fluid.layers.fill_constant([1,2], "int32", 2) # shape=[2,2]
data4 =
tensor
.full(shape=shape, dtype='bool', full_value=True) # data4=[[True,True],[True,True]]
data4 =
paddle
.full(shape=shape, dtype='bool', full_value=True) # data4=[[True,True],[True,True]]
"""
helper
=
LayerHelper
(
"full"
,
**
locals
())
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录