Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
3251f9c1
P
Paddle
项目概览
BaiXuePrincess
/
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看板
未验证
提交
3251f9c1
编写于
10月 16, 2020
作者:
C
chentianyu03
提交者:
GitHub
10月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change paddle.fluid.layers.fill_constant to paddle.full in sample codes (#27993) (#28000)
上级
164b9aab
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
19 addition
and
19 deletion
+19
-19
python/paddle/fluid/layers/control_flow.py
python/paddle/fluid/layers/control_flow.py
+11
-11
python/paddle/tensor/creation.py
python/paddle/tensor/creation.py
+5
-5
python/paddle/tensor/math.py
python/paddle/tensor/math.py
+1
-1
python/paddle/tensor/random.py
python/paddle/tensor/random.py
+2
-2
未找到文件。
python/paddle/fluid/layers/control_flow.py
浏览文件 @
3251f9c1
...
@@ -2506,21 +2506,21 @@ def case(pred_fn_pairs, default=None, name=None):
...
@@ -2506,21 +2506,21 @@ def case(pred_fn_pairs, default=None, name=None):
paddle.enable_static()
paddle.enable_static()
def fn_1():
def fn_1():
return paddle.f
luid.layers.fill_constant(shape=[1, 2], dtype='float32',
value=1)
return paddle.f
ull(shape=[1, 2], dtype='float32', fill_
value=1)
def fn_2():
def fn_2():
return paddle.f
luid.layers.fill_constant(shape=[2, 2], dtype='int32',
value=2)
return paddle.f
ull(shape=[2, 2], dtype='int32', fill_
value=2)
def fn_3():
def fn_3():
return paddle.f
luid.layers.fill_constant(shape=[3], dtype='int32',
value=3)
return paddle.f
ull(shape=[3], dtype='int32', fill_
value=3)
main_program = paddle.static.default_startup_program()
main_program = paddle.static.default_startup_program()
startup_program = paddle.static.default_main_program()
startup_program = paddle.static.default_main_program()
with paddle.static.program_guard(main_program, startup_program):
with paddle.static.program_guard(main_program, startup_program):
x = paddle.f
luid.layers.fill_constant(shape=[1], dtype='float32',
value=0.3)
x = paddle.f
ull(shape=[1], dtype='float32', fill_
value=0.3)
y = paddle.f
luid.layers.fill_constant(shape=[1], dtype='float32',
value=0.1)
y = paddle.f
ull(shape=[1], dtype='float32', fill_
value=0.1)
z = paddle.f
luid.layers.fill_constant(shape=[1], dtype='float32',
value=0.2)
z = paddle.f
ull(shape=[1], dtype='float32', fill_
value=0.2)
pred_1 = paddle.less_than(z, x) # true: 0.2 < 0.3
pred_1 = paddle.less_than(z, x) # true: 0.2 < 0.3
pred_2 = paddle.less_than(x, y) # false: 0.3 < 0.1
pred_2 = paddle.less_than(x, y) # false: 0.3 < 0.1
...
@@ -3626,19 +3626,19 @@ def switch_case(branch_index, branch_fns, default=None, name=None):
...
@@ -3626,19 +3626,19 @@ def switch_case(branch_index, branch_fns, default=None, name=None):
paddle.enable_static()
paddle.enable_static()
def fn_1():
def fn_1():
return paddle.f
luid.layers.fill_constant(shape=[1, 2], dtype='float32',
value=1)
return paddle.f
ull(shape=[1, 2], dtype='float32', fill_
value=1)
def fn_2():
def fn_2():
return paddle.f
luid.layers.fill_constant(shape=[2, 2], dtype='int32',
value=2)
return paddle.f
ull(shape=[2, 2], dtype='int32', fill_
value=2)
def fn_3():
def fn_3():
return paddle.f
luid.layers.fill_constant(shape=[3], dtype='int32',
value=3)
return paddle.f
ull(shape=[3], dtype='int32', fill_
value=3)
main_program = paddle.static.default_startup_program()
main_program = paddle.static.default_startup_program()
startup_program = paddle.static.default_main_program()
startup_program = paddle.static.default_main_program()
with paddle.static.program_guard(main_program, startup_program):
with paddle.static.program_guard(main_program, startup_program):
index_1 = paddle.f
luid.layers.fill_constant(shape=[1], dtype='int32',
value=1)
index_1 = paddle.f
ull(shape=[1], dtype='int32', fill_
value=1)
index_2 = paddle.f
luid.layers.fill_constant(shape=[1], dtype='int32',
value=2)
index_2 = paddle.f
ull(shape=[1], dtype='int32', fill_
value=2)
out_1 = paddle.static.nn.switch_case(
out_1 = paddle.static.nn.switch_case(
branch_index=index_1,
branch_index=index_1,
...
...
python/paddle/tensor/creation.py
浏览文件 @
3251f9c1
...
@@ -312,7 +312,7 @@ def ones(shape, dtype=None, name=None):
...
@@ -312,7 +312,7 @@ def ones(shape, dtype=None, name=None):
# [1 1]]
# [1 1]]
# shape is a Tensor
# shape is a Tensor
shape = paddle.f
luid.layers.fill_constant(shape=[2], dtype='int32',
value=2)
shape = paddle.f
ull(shape=[2], dtype='int32', fill_
value=2)
data3 = paddle.ones(shape=shape, dtype='int32')
data3 = paddle.ones(shape=shape, dtype='int32')
# [[1 1]
# [[1 1]
# [1 1]]
# [1 1]]
...
@@ -393,7 +393,7 @@ def zeros(shape, dtype=None, name=None):
...
@@ -393,7 +393,7 @@ def zeros(shape, dtype=None, name=None):
# [0. 0.]]
# [0. 0.]]
# shape is a Tensor
# shape is a Tensor
shape = paddle.f
luid.layers.fill_constant(shape=[2], dtype='int32',
value=2)
shape = paddle.f
ull(shape=[2], dtype='int32', fill_
value=2)
data3 = paddle.zeros(shape=shape, dtype='int32')
data3 = paddle.zeros(shape=shape, dtype='int32')
# [[0 0]
# [[0 0]
# [0 0]]
# [0 0]]
...
@@ -521,18 +521,18 @@ def full(shape, fill_value, dtype=None, name=None):
...
@@ -521,18 +521,18 @@ def full(shape, fill_value, dtype=None, name=None):
# [0]]
# [0]]
# attr shape is a list which contains Tensor.
# attr shape is a list which contains Tensor.
positive_2 = paddle.f
luid.layers.fill_constant([1], "int32", 2
)
positive_2 = paddle.f
ull([1], 2, "int32"
)
data3 = paddle.full(shape=[1, positive_2], dtype='float32', fill_value=1.5)
data3 = paddle.full(shape=[1, positive_2], dtype='float32', fill_value=1.5)
# [[1.5 1.5]]
# [[1.5 1.5]]
# attr shape is a Tensor.
# attr shape is a Tensor.
shape = paddle.f
luid.layers.fill_constant([2], "int32", 2
)
shape = paddle.f
ull([2], 2, "int32"
)
data4 = paddle.full(shape=shape, dtype='bool', fill_value=True)
data4 = paddle.full(shape=shape, dtype='bool', fill_value=True)
# [[True True]
# [[True True]
# [True True]]
# [True True]]
# attr fill_value is a Tensor.
# attr fill_value is a Tensor.
val = paddle.f
luid.layers.fill_constant([1], "float32", 2.0
)
val = paddle.f
ull([1], 2.0, "float32"
)
data5 = paddle.full(shape=[2,1], fill_value=val, dtype='float32')
data5 = paddle.full(shape=[2,1], fill_value=val, dtype='float32')
# [[2.0]
# [[2.0]
# [2.0]]
# [2.0]]
...
...
python/paddle/tensor/math.py
浏览文件 @
3251f9c1
...
@@ -170,7 +170,7 @@ def pow(x, y, name=None):
...
@@ -170,7 +170,7 @@ def pow(x, y, name=None):
print(res.numpy()) # [1 4 9]
print(res.numpy()) # [1 4 9]
# example 2: y is a Tensor
# example 2: y is a Tensor
y = paddle.f
luid.layers.fill_constant(shape=[1],
value=2, dtype='float32')
y = paddle.f
ull(shape=[1], fill_
value=2, dtype='float32')
res = paddle.pow(x, y)
res = paddle.pow(x, y)
print(res.numpy()) # [1 4 9]
print(res.numpy()) # [1 4 9]
...
...
python/paddle/tensor/random.py
浏览文件 @
3251f9c1
...
@@ -431,8 +431,8 @@ def uniform(shape, dtype=None, min=-1.0, max=1.0, seed=0, name=None):
...
@@ -431,8 +431,8 @@ def uniform(shape, dtype=None, min=-1.0, max=1.0, seed=0, name=None):
# example 2:
# example 2:
# attr shape is a list which contains Tensor.
# attr shape is a list which contains Tensor.
dim_1 = paddle.f
luid.layers.fill_constant([1], "int64", 2
)
dim_1 = paddle.f
ull([1], 2, "int64"
)
dim_2 = paddle.f
luid.layers.fill_constant([1], "int32", 3
)
dim_2 = paddle.f
ull([1], 3, "int32"
)
result_2 = paddle.tensor.random.uniform(shape=[dim_1, dim_2])
result_2 = paddle.tensor.random.uniform(shape=[dim_1, dim_2])
# [[-0.9951253, 0.30757582, 0.9899647 ],
# [[-0.9951253, 0.30757582, 0.9899647 ],
# [ 0.5864527, 0.6607096, -0.8886161 ]]
# [ 0.5864527, 0.6607096, -0.8886161 ]]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录