Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
614f20f6
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
614f20f6
编写于
11月 12, 2020
作者:
Y
Yang Zhang
提交者:
GitHub
11月 12, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update `add` `clip` `MSELoss` and `no_grad` (#28530)
also fix `no_grad` alias
上级
8699f38d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
6 addition
and
18 deletion
+6
-18
python/paddle/__init__.py
python/paddle/__init__.py
+0
-1
python/paddle/fluid/dygraph/base.py
python/paddle/fluid/dygraph/base.py
+0
-2
python/paddle/framework/__init__.py
python/paddle/framework/__init__.py
+1
-1
python/paddle/nn/layer/loss.py
python/paddle/nn/layer/loss.py
+1
-2
python/paddle/tensor/math.py
python/paddle/tensor/math.py
+4
-12
未找到文件。
python/paddle/__init__.py
浏览文件 @
614f20f6
...
...
@@ -263,7 +263,6 @@ from .device import XPUPlace
from
.fluid.dygraph.base
import
enable_dygraph
as
disable_static
#DEFINE_ALIAS
from
.fluid.dygraph.base
import
disable_dygraph
as
enable_static
#DEFINE_ALIAS
from
.fluid.framework
import
in_dygraph_mode
as
in_dynamic_mode
#DEFINE_ALIAS
from
.fluid.dygraph.base
import
no_grad_
as
no_grad
#DEFINE_ALIAS
from
.fluid.layers
import
crop_tensor
as
crop
#DEFINE_ALIAS
from
.
import
jit
...
...
python/paddle/fluid/dygraph/base.py
浏览文件 @
614f20f6
...
...
@@ -272,8 +272,6 @@ class no_grad_:
import numpy as np
import paddle
paddle.disable_static()
# use as generator
data = np.array([[2, 3], [4, 5]]).astype('float32')
...
...
python/paddle/framework/__init__.py
浏览文件 @
614f20f6
...
...
@@ -38,7 +38,7 @@ from ..fluid.core import CUDAPinnedPlace #DEFINE_ALIAS
from
..fluid.core
import
VarBase
#DEFINE_ALIAS
from
paddle.fluid
import
core
#DEFINE_ALIAS
from
..fluid.dygraph.base
import
no_grad
#DEFINE_ALIAS
from
..fluid.dygraph.base
import
no_grad
_
as
no_grad
#DEFINE_ALIAS
from
..fluid.dygraph.base
import
to_variable
#DEFINE_ALIAS
from
..fluid.dygraph.base
import
grad
#DEFINE_ALIAS
from
.io
import
save
...
...
python/paddle/nn/layer/loss.py
浏览文件 @
614f20f6
...
...
@@ -418,12 +418,11 @@ class MSELoss(fluid.dygraph.layers.Layer):
input_data = np.array([1.5]).astype("float32")
label_data = np.array([1.7]).astype("float32")
paddle.disable_static()
mse_loss = paddle.nn.loss.MSELoss()
input = paddle.to_tensor(input_data)
label = paddle.to_tensor(label_data)
output = mse_loss(input, label)
print(output
.numpy()
)
print(output)
# [0.04000002]
"""
...
...
python/paddle/tensor/math.py
浏览文件 @
614f20f6
...
...
@@ -274,18 +274,15 @@ def _elementwise_op(helper):
def
add
(
x
,
y
,
name
=
None
):
"""
Examples:
Examples:
.. code-block:: python
import paddle
paddle.disable_static()
x = paddle.to_tensor([2, 3, 4], 'float64')
y = paddle.to_tensor([1, 5, 2], 'float64')
z = paddle.add(x, y)
np_z = z.numpy()
print(np_z) # [3., 8., 6. ]
print(z) # [3., 8., 6. ]
"""
op_type
=
'elementwise_add'
...
...
@@ -1411,9 +1408,6 @@ def addcmul(input, tensor1, tensor2, value=1.0, name=None):
def
clip
(
x
,
min
=
None
,
max
=
None
,
name
=
None
):
"""
:alias_main: paddle.clip
:alias: paddle.clip,paddle.tensor.clip,paddle.tensor.math.clip
**clip layer**
This operator clip all elements in input into the range [ min, max ] and return
...
...
@@ -1440,15 +1434,13 @@ def clip(x, min=None, max=None, name=None):
.. code-block:: python
import paddle
paddle.disable_static()
x1 = paddle.to_tensor([[1.2, 3.5], [4.5, 6.4]], 'float32')
out1 = paddle.clip(x1, min=3.5, max=5.0)
out2 = paddle.clip(x1, min=2.5)
print(out1
.numpy()
)
print(out1)
# [[3.5, 3.5]
# [4.5, 5.0]]
print(out2
.numpy()
)
print(out2)
# [[2.5, 3.5]
# [[4.5, 6.4]
"""
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录