Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wzpei9
Paddle
提交
edf36423
P
Paddle
项目概览
wzpei9
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
edf36423
编写于
4月 06, 2017
作者:
D
dangqingqing
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add extra_layers in paddle.trainer.SGD.
上级
d94e1f51
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
10 deletion
+24
-10
python/paddle/v2/layer.py
python/paddle/v2/layer.py
+6
-1
python/paddle/v2/topology.py
python/paddle/v2/topology.py
+16
-7
python/paddle/v2/trainer.py
python/paddle/v2/trainer.py
+2
-2
未找到文件。
python/paddle/v2/layer.py
浏览文件 @
edf36423
...
...
@@ -53,7 +53,7 @@ import data_type
__all__
=
[
'parse_network'
,
'data'
]
def
parse_network
(
*
outputs
):
def
parse_network
(
*
outputs
,
**
kwargs
):
"""
Parse all output layers and then generate a ModelConfig object.
...
...
@@ -75,6 +75,11 @@ def parse_network(*outputs):
"""
context
=
dict
()
real_output
=
[
each
.
to_proto
(
context
=
context
)
for
each
in
outputs
]
extra_layers
=
kwargs
.
get
(
'extra_layers'
,
None
)
if
extra_layers
is
not
None
:
extra_output
=
[
each
.
to_proto
(
context
=
context
)
for
each
in
extra_layers
]
conf_helps
.
outputs
(
real_output
)
return
__parse__
(
__real_func__
)
...
...
python/paddle/v2/topology.py
浏览文件 @
edf36423
...
...
@@ -53,14 +53,23 @@ class Topology(object):
and network configs.
"""
def
__init__
(
self
,
layers
):
if
not
isinstance
(
layers
,
collections
.
Sequence
):
__check_layer_type__
(
layers
)
layers
=
[
layers
]
for
layer
in
layers
:
__check_layer_type__
(
layer
)
def
__init__
(
self
,
layers
,
extra_layers
=
None
):
def
__check__
(
layers
):
if
not
isinstance
(
layers
,
collections
.
Sequence
):
__check_layer_type__
(
layers
)
layers
=
[
layers
]
for
layer
in
layers
:
__check_layer_type__
(
layer
)
return
layers
layers
=
__check__
(
layers
)
self
.
layers
=
layers
self
.
__model_config__
=
v2_layer
.
parse_network
(
*
layers
)
if
extra_layers
is
not
None
:
extra_layers
=
__check__
(
extra_layers
)
self
.
layers
.
extend
(
extra_layers
)
self
.
__model_config__
=
v2_layer
.
parse_network
(
*
layers
,
extra_layers
=
extra_layers
)
assert
isinstance
(
self
.
__model_config__
,
ModelConfig
)
def
proto
(
self
):
...
...
python/paddle/v2/trainer.py
浏览文件 @
edf36423
...
...
@@ -39,7 +39,7 @@ class SGD(object):
:type parameters: paddle.v2.parameters.Parameters
"""
def
__init__
(
self
,
cost
,
parameters
,
update_equation
):
def
__init__
(
self
,
cost
,
parameters
,
update_equation
,
extra_layers
=
None
):
if
not
isinstance
(
parameters
,
v2_parameters
.
Parameters
):
raise
TypeError
(
'parameters should be parameters'
)
...
...
@@ -47,7 +47,7 @@ class SGD(object):
if
not
isinstance
(
update_equation
,
v2_optimizer
.
Optimizer
):
raise
TypeError
(
"update equation parameter must be "
"paddle.v2.optimizer.Optimizer"
)
topology
=
Topology
(
cost
)
topology
=
Topology
(
cost
,
extra_layers
=
extra_layers
)
self
.
__optimizer__
=
update_equation
self
.
__topology__
=
topology
self
.
__parameters__
=
parameters
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录