Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
9c59d42b
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
9c59d42b
编写于
2月 17, 2023
作者:
W
whisky-12
提交者:
GitHub
2月 17, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[note]-MSELoss- API英文文档中包含报错信息的问题修复 (#49577)
上级
53df9884
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
0 deletion
+13
-0
python/paddle/nn/layer/loss.py
python/paddle/nn/layer/loss.py
+13
-0
未找到文件。
python/paddle/nn/layer/loss.py
浏览文件 @
9c59d42b
...
@@ -525,16 +525,24 @@ class MSELoss(Layer):
...
@@ -525,16 +525,24 @@ class MSELoss(Layer):
r
"""
r
"""
**Mean Square Error Loss**
**Mean Square Error Loss**
Computes the mean square error (squared L2 norm) of given input and label.
Computes the mean square error (squared L2 norm) of given input and label.
If :attr:`reduction` is set to ``'none'``, loss is calculated as:
If :attr:`reduction` is set to ``'none'``, loss is calculated as:
.. math::
.. math::
Out = (input - label)^2
Out = (input - label)^2
If :attr:`reduction` is set to ``'mean'``, loss is calculated as:
If :attr:`reduction` is set to ``'mean'``, loss is calculated as:
.. math::
.. math::
Out = \operatorname{mean}((input - label)^2)
Out = \operatorname{mean}((input - label)^2)
If :attr:`reduction` is set to ``'sum'``, loss is calculated as:
If :attr:`reduction` is set to ``'sum'``, loss is calculated as:
.. math::
.. math::
Out = \operatorname{sum}((input - label)^2)
Out = \operatorname{sum}((input - label)^2)
where `input` and `label` are `float32` tensors of same shape.
where `input` and `label` are `float32` tensors of same shape.
Parameters:
Parameters:
reduction (str, optional): The reduction method for the output,
reduction (str, optional): The reduction method for the output,
could be 'none' | 'mean' | 'sum'.
could be 'none' | 'mean' | 'sum'.
...
@@ -542,12 +550,16 @@ class MSELoss(Layer):
...
@@ -542,12 +550,16 @@ class MSELoss(Layer):
If :attr:`size_average` is ``'sum'``, the reduced sum loss is returned.
If :attr:`size_average` is ``'sum'``, the reduced sum loss is returned.
If :attr:`reduction` is ``'none'``, the unreduced loss is returned.
If :attr:`reduction` is ``'none'``, the unreduced loss is returned.
Default is ``'mean'``.
Default is ``'mean'``.
Shape:
Shape:
input (Tensor): Input tensor, the data type is float32 or float64
input (Tensor): Input tensor, the data type is float32 or float64
label (Tensor): Label tensor, the data type is float32 or float64
label (Tensor): Label tensor, the data type is float32 or float64
output (Tensor): output tensor storing the MSE loss of input and label, the data type is same as input.
output (Tensor): output tensor storing the MSE loss of input and label, the data type is same as input.
Examples:
Examples:
.. code-block:: python
.. code-block:: python
import paddle
import paddle
mse_loss = paddle.nn.loss.MSELoss()
mse_loss = paddle.nn.loss.MSELoss()
input = paddle.to_tensor([1.5])
input = paddle.to_tensor([1.5])
...
@@ -555,6 +567,7 @@ class MSELoss(Layer):
...
@@ -555,6 +567,7 @@ class MSELoss(Layer):
output = mse_loss(input, label)
output = mse_loss(input, label)
print(output)
print(output)
# [0.04000002]
# [0.04000002]
"""
"""
def
__init__
(
self
,
reduction
=
'mean'
):
def
__init__
(
self
,
reduction
=
'mean'
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录