Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
655d5eb1
P
Paddle
项目概览
Crayon鑫
/
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看板
未验证
提交
655d5eb1
编写于
11月 20, 2020
作者:
B
Bai Yifan
提交者:
GitHub
11月 20, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix code example (#28636)
* fix code example, test=document_fix
上级
8b853b30
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
22 addition
and
34 deletion
+22
-34
python/paddle/fluid/layers/loss.py
python/paddle/fluid/layers/loss.py
+6
-1
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+12
-10
python/paddle/nn/functional/loss.py
python/paddle/nn/functional/loss.py
+1
-22
python/paddle/nn/functional/pooling.py
python/paddle/nn/functional/pooling.py
+3
-1
未找到文件。
python/paddle/fluid/layers/loss.py
浏览文件 @
655d5eb1
...
...
@@ -329,10 +329,15 @@ def square_error_cost(input, label):
input = paddle.to_tensor([1.1, 1.9])
label = paddle.to_tensor([1.0, 2.0])
output = paddle.nn.functional.square_error_cost(input, label)
print(output
.numpy()
)
print(output)
# [0.01, 0.01]
"""
if
in_dygraph_mode
():
minus_out
=
core
.
ops
.
elementwise_sub
(
input
,
label
)
square_out
=
core
.
ops
.
square
(
minus_out
)
return
square_out
check_variable_and_dtype
(
input
,
"input"
,
[
'float32'
,
'float64'
],
'square_error_cost'
)
check_variable_and_dtype
(
label
,
"label"
,
[
'float32'
,
'float64'
],
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
655d5eb1
...
...
@@ -5698,16 +5698,18 @@ def row_conv(input, future_context_size, param_attr=None, act=None):
${out_comment}.
Examples:
>>> # for LodTensor inputs
>>> import paddle.fluid as fluid
>>> import paddle
>>> paddle.enable_static()
>>> x = fluid.data(name='x', shape=[9, 16],
>>> dtype='float32', lod_level=1)
>>> out = fluid.layers.row_conv(input=x, future_context_size=2)
>>> # for Tensor inputs
>>> x = fluid.data(name='x', shape=[9, 4, 16], dtype='float32')
>>> out = fluid.layers.row_conv(input=x, future_context_size=2)
.. code-block:: python
# for LodTensor inputs
import paddle
paddle.enable_static()
x = paddle.static.data(name='x', shape=[9, 16],
dtype='float32', lod_level=1)
out = paddle.static.nn.row_conv(input=x, future_context_size=2)
# for Tensor inputs
x = paddle.static.data(name='x', shape=[9, 4, 16], dtype='float32')
out = paddle.static.nn.row_conv(input=x, future_context_size=2)
"""
helper = LayerHelper('row_conv', **locals())
check_variable_and_dtype(input, 'input', ['float32'], 'row_conv')
...
...
python/paddle/nn/functional/loss.py
浏览文件 @
655d5eb1
...
...
@@ -989,32 +989,11 @@ def mse_loss(input, label, reduction='mean', name=None):
.. code-block:: python
import paddle
# static graph mode
paddle.enable_static()
mse_loss = paddle.nn.loss.MSELoss()
input = paddle.fluid.data(name="input", shape=[1])
label = paddle.fluid.data(name="label", shape=[1])
place = paddle.CPUPlace()
output = mse_loss(input,label)
exe = paddle.static.Executor(place)
exe.run(paddle.static.default_startup_program())
output_data = exe.run(
paddle.static.default_main_program(),
feed={"input":input_data, "label":label_data},
fetch_list=[output],
return_numpy=True)
print(output_data)
# [array([0.04000002], dtype=float32)]
# dynamic graph mode
paddle.disable_static()
input = paddle.to_tensor(1.5)
label = paddle.to_tensor(1.7)
output = mse_loss(input, label)
print(output
.numpy()
)
print(output)
# [0.04000002]
"""
...
...
python/paddle/nn/functional/pooling.py
浏览文件 @
655d5eb1
...
...
@@ -887,6 +887,7 @@ def adaptive_avg_pool1d(x, output_size, name=None):
ValueError: 'output_size' should be an integer.
Examples:
.. code-block:: python
# average adaptive pool1d
# suppose input data in shape of [N, C, L], `output_size` is m or [m],
# output shape is [N, C, m], adaptive pool divide L dimension
...
...
@@ -961,6 +962,7 @@ def adaptive_avg_pool2d(x, output_size, data_format='NCHW', name=None):
ValueError: If `data_format` is not "NCHW" or "NHWC".
Examples:
.. code-block:: python
# adaptive avg pool2d
# suppose input data in shape of [N, C, H, W], `output_size` is [m, n],
# output shape is [N, C, m, n], adaptive pool divide H and W dimensions
...
...
@@ -1062,6 +1064,7 @@ def adaptive_avg_pool3d(x, output_size, data_format='NCDHW', name=None):
ValueError: If `data_format` is not "NCDHW" or "NDHWC".
Examples:
.. code-block:: python
# adaptive avg pool3d
# suppose input data in shape of [N, C, D, H, W], `output_size` is [l, m, n],
# output shape is [N, C, l, m, n], adaptive pool divide D, H and W dimensions
...
...
@@ -1082,7 +1085,6 @@ def adaptive_avg_pool3d(x, output_size, data_format='NCDHW', name=None):
# avg(input[:, :, dstart:dend, hstart: hend, wstart: wend])
import paddle
import numpy as np
input_data = np.random.rand(2, 3, 8, 32, 32)
x = paddle.to_tensor(input_data)
# x.shape is [2, 3, 8, 32, 32]
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录