Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
暴走的小小菜鸟
Paddle
提交
ea9e62b8
P
Paddle
项目概览
暴走的小小菜鸟
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ea9e62b8
编写于
2月 26, 2018
作者:
Q
qiaolongfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
optimize code
上级
a636aa58
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
4 addition
and
4 deletion
+4
-4
python/paddle/fluid/optimizer.py
python/paddle/fluid/optimizer.py
+4
-4
未找到文件。
python/paddle/fluid/optimizer.py
浏览文件 @
ea9e62b8
...
@@ -38,13 +38,13 @@ class Optimizer(object):
...
@@ -38,13 +38,13 @@ class Optimizer(object):
def
__init__
(
self
,
learning_rate
,
global_step
=
None
,
regularization
=
None
):
def
__init__
(
self
,
learning_rate
,
global_step
=
None
,
regularization
=
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
Valu
eError
(
"learning rate should be float or Variable"
)
raise
Typ
eError
(
"learning rate should be float or Variable"
)
self
.
_global_step
=
global_step
self
.
_global_step
=
global_step
self
.
regularization
=
regularization
self
.
regularization
=
regularization
self
.
_learning_rate
=
learning_rate
self
.
_learning_rate
=
learning_rate
# each program should have a independent learning rate
# each program should have a independent learning rate
# program -> Variable(learning_rate)
# program -> Variable(learning_rate)
self
.
_learning_rate_map
=
d
efaultdict
(
lambda
:
None
)
self
.
_learning_rate_map
=
d
ict
(
)
if
isinstance
(
self
.
_learning_rate
,
framework
.
Variable
):
if
isinstance
(
self
.
_learning_rate
,
framework
.
Variable
):
self
.
_learning_rate_map
[
framework
.
default_main_program
(
self
.
_learning_rate_map
[
framework
.
default_main_program
(
)]
=
self
.
_learning_rate
)]
=
self
.
_learning_rate
...
@@ -62,7 +62,7 @@ class Optimizer(object):
...
@@ -62,7 +62,7 @@ class Optimizer(object):
return
return
else
:
else
:
if
not
isinstance
(
self
.
_learning_rate
,
float
):
if
not
isinstance
(
self
.
_learning_rate
,
float
):
raise
Valu
eError
(
raise
Typ
eError
(
"learning rate variable is create outside optimizer,"
"learning rate variable is create outside optimizer,"
"can not create new learning rate variable for new program"
)
"can not create new learning rate variable for new program"
)
...
@@ -82,7 +82,7 @@ class Optimizer(object):
...
@@ -82,7 +82,7 @@ class Optimizer(object):
"""
"""
if
program
is
None
:
if
program
is
None
:
program
=
framework
.
default_main_program
()
program
=
framework
.
default_main_program
()
return
self
.
_learning_rate_map
[
program
]
return
self
.
_learning_rate_map
.
get
(
program
,
None
)
def
_append_optimize_op
(
self
,
block
,
param_and_grad
):
def
_append_optimize_op
(
self
,
block
,
param_and_grad
):
""" append optimize operator to block and return all the added optimize_op
""" append optimize operator to block and return all the added optimize_op
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录