Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
9be39bb4
P
Paddle
项目概览
PaddlePaddle
/
Paddle
接近 2 年 前同步成功
通知
2323
Star
20933
Fork
5424
代码
文件
提交
分支
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看板
未验证
提交
9be39bb4
编写于
8月 28, 2018
作者:
W
whs
提交者:
GitHub
8月 28, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enhence optimizer. (#13004)
上级
7ad39c40
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
7 addition
and
1 deletion
+7
-1
python/paddle/fluid/optimizer.py
python/paddle/fluid/optimizer.py
+7
-1
未找到文件。
python/paddle/fluid/optimizer.py
浏览文件 @
9be39bb4
...
@@ -46,10 +46,12 @@ class Optimizer(object):
...
@@ -46,10 +46,12 @@ class Optimizer(object):
def
__init__
(
self
,
def
__init__
(
self
,
learning_rate
,
learning_rate
,
regularization
=
None
,
regularization
=
None
,
LARS_weight_decay
=
0.0
):
LARS_weight_decay
=
0.0
,
name
=
None
):
if
not
isinstance
(
learning_rate
,
float
)
and
\
if
not
isinstance
(
learning_rate
,
float
)
and
\
not
isinstance
(
learning_rate
,
framework
.
Variable
):
not
isinstance
(
learning_rate
,
framework
.
Variable
):
raise
TypeError
(
"learning rate should be float or Variable"
)
raise
TypeError
(
"learning rate should be float or Variable"
)
self
.
_name
=
name
self
.
regularization
=
regularization
self
.
regularization
=
regularization
self
.
_learning_rate
=
learning_rate
self
.
_learning_rate
=
learning_rate
# the learning rate type should be inferenced from loss
# the learning rate type should be inferenced from loss
...
@@ -153,6 +155,8 @@ class Optimizer(object):
...
@@ -153,6 +155,8 @@ class Optimizer(object):
dtype: data type of the accumulator variable
dtype: data type of the accumulator variable
fill_value: value to initialize the accumulator variable
fill_value: value to initialize the accumulator variable
"""
"""
if
self
.
_name
is
not
None
:
name
=
self
.
_name
+
"_"
+
name
if
(
name
in
self
.
_accumulators
and
if
(
name
in
self
.
_accumulators
and
param
.
name
in
self
.
_accumulators
[
name
]):
param
.
name
in
self
.
_accumulators
[
name
]):
raise
Exception
(
"Accumulator {} already exists for parameter {}"
.
raise
Exception
(
"Accumulator {} already exists for parameter {}"
.
...
@@ -181,6 +185,8 @@ class Optimizer(object):
...
@@ -181,6 +185,8 @@ class Optimizer(object):
Returns:
Returns:
accumulator variable for the parameter
accumulator variable for the parameter
"""
"""
if
self
.
_name
is
not
None
:
name
=
self
.
_name
+
"_"
+
name
if
(
name
not
in
self
.
_accumulators
or
if
(
name
not
in
self
.
_accumulators
or
param
.
name
not
in
self
.
_accumulators
[
name
]):
param
.
name
not
in
self
.
_accumulators
[
name
]):
raise
Exception
(
"Accumulator {} does not exist for parameter {}"
.
raise
Exception
(
"Accumulator {} does not exist for parameter {}"
.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录