Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
692d2518
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
692d2518
编写于
6月 05, 2017
作者:
C
caoying03
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add missing configuration functions in v2 API.
上级
e4c97e48
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
62 addition
and
57 deletion
+62
-57
doc/api/v2/config/layer.rst
doc/api/v2/config/layer.rst
+9
-1
doc/api/v2/config/networks.rst
doc/api/v2/config/networks.rst
+0
-8
python/paddle/trainer/config_parser.py
python/paddle/trainer/config_parser.py
+6
-6
python/paddle/trainer_config_helpers/layers.py
python/paddle/trainer_config_helpers/layers.py
+24
-2
python/paddle/trainer_config_helpers/networks.py
python/paddle/trainer_config_helpers/networks.py
+4
-27
python/paddle/v2/layer.py
python/paddle/v2/layer.py
+17
-12
python/paddle/v2/topology.py
python/paddle/v2/topology.py
+2
-1
未找到文件。
doc/api/v2/config/layer.rst
浏览文件 @
692d2518
...
...
@@ -434,10 +434,18 @@ smooth_l1_cost
.. autoclass:: paddle.v2.layer.smooth_l1_cost
:noindex:
Check Layer
Check Layer
============
eos
---
.. autoclass:: paddle.v2.layer.eos
:noindex:
Miscs
=====
dropout
--------------
.. autoclass:: paddle.v2.layer.dropout
:noindex:
doc/api/v2/config/networks.rst
浏览文件 @
692d2518
...
...
@@ -125,11 +125,3 @@ simple_attention
:members: simple_attention
:noindex:
Miscs
=====
dropout_layer
--------------
.. automodule:: paddle.v2.networks
:members: dropout_layer
:noindex:
python/paddle/trainer/config_parser.py
浏览文件 @
692d2518
...
...
@@ -3546,11 +3546,7 @@ def update_g_config():
return
g_config
def
begin_parse
(
config_arg_str
=
''
):
'''
@param config_arg_str: a string of the form var1=val1,var2=val2. It will be
passed to config script as a dictionary CONFIG_ARGS
'''
def
begin_parse
():
init_config_environment
()
for
hook
in
_parse_config_hooks
:
hook
()
...
...
@@ -3568,8 +3564,12 @@ def begin_parse(config_arg_str=''):
def
parse_config
(
trainer_config
,
config_arg_str
):
begin_parse
(
config_arg_str
)
'''
@param config_arg_str: a string of the form var1=val1,var2=val2. It will be
passed to config script as a dictionary CONFIG_ARGS
'''
begin_parse
()
config_args
=
{}
if
config_arg_str
:
...
...
python/paddle/trainer_config_helpers/layers.py
浏览文件 @
692d2518
...
...
@@ -120,6 +120,7 @@ __all__ = [
'smooth_l1_cost'
,
'layer_support'
,
'multiplex_layer'
,
'dropout_layer'
,
]
...
...
@@ -3760,7 +3761,6 @@ def beam_search(step,
assert
generated_input_index
!=
-
1
gipt
=
input
[
generated_input_index
]
assert
isinstance
(
gipt
,
BaseGeneratedInput
)
gipt
.
bos_id
=
bos_id
gipt
.
eos_id
=
eos_id
...
...
@@ -3780,7 +3780,6 @@ def beam_search(step,
predict
=
gipt
.
after_real_step
(
step
(
*
args
))
eos_layer
(
input
=
predict
,
eos_id
=
eos_id
,
name
=
eos_name
)
return
predict
tmp
=
recurrent_group
(
...
...
@@ -5543,3 +5542,26 @@ def multiplex_layer(input, name=None, layer_attr=None):
layer_type
=
LayerType
.
MULTIPLEX_LAYER
,
parents
=
input
,
size
=
l
.
config
.
size
)
############################################################################
# Miscs #
############################################################################
@
wrap_name_default
(
"dropout"
)
def
dropout_layer
(
input
,
dropout_rate
,
name
=
None
):
"""
@TODO(yuyang18): Add comments.
:param name:
:param input:
:param dropout_rate:
:return:
"""
return
addto_layer
(
name
=
name
,
input
=
input
,
act
=
LinearActivation
(),
bias_attr
=
False
,
layer_attr
=
ExtraAttr
(
drop_rate
=
dropout_rate
))
python/paddle/trainer_config_helpers/networks.py
浏览文件 @
692d2518
...
...
@@ -26,10 +26,10 @@ from paddle.trainer.config_parser import *
__all__
=
[
'sequence_conv_pool'
,
'simple_lstm'
,
"simple_img_conv_pool"
,
"img_conv_bn_pool"
,
'
dropout_layer'
,
'lstmemory_group'
,
'lstmemory_unit
'
,
'
small_vgg'
,
'img_conv_group'
,
'vgg_16_network'
,
'gru_unit'
,
'gru_group
'
,
'simple_
gru'
,
'simple_attention'
,
'simple_gru2'
,
'bidirectional_gru
'
,
'
text_conv_pool'
,
'
bidirectional_lstm'
,
'inputs'
,
'outputs'
"img_conv_bn_pool"
,
'
lstmemory_group'
,
'lstmemory_unit'
,
'small_vgg
'
,
'
img_conv_group'
,
'vgg_16_network'
,
'gru_unit'
,
'gru_group'
,
'simple_gru
'
,
'simple_
attention'
,
'simple_gru2'
,
'bidirectional_gru'
,
'text_conv_pool
'
,
'bidirectional_lstm'
,
'inputs'
,
'outputs'
]
######################################################
...
...
@@ -1366,29 +1366,6 @@ def simple_attention(encoded_sequence,
input
=
scaled
,
pooling_type
=
SumPooling
(),
name
=
"%s_pooling"
%
name
)
############################################################################
# Miscs #
############################################################################
@
wrap_name_default
(
"dropout"
)
def
dropout_layer
(
input
,
dropout_rate
,
name
=
None
):
"""
@TODO(yuyang18): Add comments.
:param name:
:param input:
:param dropout_rate:
:return:
"""
return
addto_layer
(
name
=
name
,
input
=
input
,
act
=
LinearActivation
(),
bias_attr
=
False
,
layer_attr
=
ExtraAttr
(
drop_rate
=
dropout_rate
))
def
inputs
(
layers
,
*
args
):
"""
Declare the inputs of network. The order of input should be as same as
...
...
python/paddle/v2/layer.py
浏览文件 @
692d2518
...
...
@@ -13,7 +13,7 @@
# limitations under the License.
"""
`paddle.v2.layer` is a part of model config packages in paddle.v2. In API v2,
we want to make Paddle a plain Python package. The model config package define
d
we want to make Paddle a plain Python package. The model config package define
s
the way how to configure a neural network topology in Paddle Python code.
The primary usage shows below.
...
...
@@ -30,7 +30,6 @@ The primary usage shows below.
# use prediction instance where needed.
parameters = paddle.parameters.create(cost)
"""
import
collections
import
copy
import
re
...
...
@@ -44,9 +43,10 @@ __all__ = ['data', 'parse_network']
def
__need_to_keep__
(
name
):
if
name
in
[
'StaticInput'
,
'LayerType'
,
'layer_support'
]:
return
False
return
True
return
name
in
[
'StaticInput'
,
'SubsequenceInput'
,
'GeneratedInput'
,
'LayerType'
,
'layer_support'
]
def
__need_to_wrap__
(
name
):
...
...
@@ -54,6 +54,8 @@ def __need_to_wrap__(name):
def
__convert_name__
(
inname
):
if
__need_to_keep__
(
inname
):
return
inname
if
inname
==
'maxid_layer'
:
return
'max_id'
elif
inname
.
endswith
(
'memory'
)
or
inname
.
endswith
(
...
...
@@ -74,8 +76,6 @@ def __convert_name__(inname):
for
name
in
v1_layers
.
__all__
:
obj
=
getattr
(
v1_layers
,
name
)
if
not
__need_to_keep__
(
name
):
continue
new_name
=
__convert_name__
(
name
)
if
callable
(
obj
)
and
__need_to_wrap__
(
name
):
globals
()[
new_name
]
=
__convert_to_v2__
(
obj
,
new_name
,
__name__
)
...
...
@@ -107,7 +107,7 @@ __data_layer__.__doc__ = __map_data_docstr__(v1_layers.data_layer.__doc__)
data
=
__convert_to_v2__
(
__data_layer__
,
'name'
,
__name__
)
def
__get_used_layers__
(
output_layers
,
extra_layers
=
None
):
def
__get_used_layers__
(
output_layers
):
layer_names
=
set
()
parents
=
{}
...
...
@@ -175,6 +175,8 @@ def __get_used_submodels__(layer_names):
for
submodel
in
cp
.
g_config
.
model_config
.
sub_models
:
if
submodel
.
name
in
layer_names
:
submodel_names
.
add
(
submodel
.
name
)
if
submodel
.
is_recurrent_layer_group
:
layer_names
|=
set
(
submodel
.
layer_names
)
return
submodel_names
...
...
@@ -248,18 +250,21 @@ def parse_network(output_layers, extra_layers=None):
model_config
=
ModelConfig
()
model_config
.
type
=
cp
.
g_config
.
model_config
.
type
for
layer
in
output_layers
:
model_config
.
output_layer_names
.
append
(
layer
.
full_name
)
output_layer_names
.
add
(
layer
.
full_name
)
for
l
in
cp
.
g_config
.
model_config
.
layers
:
if
l
.
name
not
in
layer_names
:
continue
model_config
.
layers
.
extend
([
l
])
if
l
.
type
==
'data'
:
if
l
.
name
in
model_config
.
output_layer_names
:
continue
model_config
.
input_layer_names
.
append
(
l
.
name
)
input_layer_names
.
add
(
l
.
name
)
for
layer
in
output_layers
:
model_config
.
output_layer_names
.
append
(
layer
.
full_name
)
output_layer_names
.
add
(
layer
.
full_name
)
for
e
in
cp
.
g_config
.
model_config
.
evaluators
:
if
e
.
name
in
evaluator_names
:
model_config
.
evaluators
.
extend
([
e
])
...
...
python/paddle/v2/topology.py
浏览文件 @
692d2518
...
...
@@ -91,8 +91,9 @@ class Topology(object):
[('image', dense_vector(768)), ('label', integer_value(10))]
"""
data_layers
=
self
.
data_layers
()
return
[(
nm
,
data_layers
[
nm
].
data_type
)
for
nm
in
self
.
proto
().
input_layer_names
]
for
nm
in
self
.
proto
().
input_layer_names
if
nm
in
data_layers
]
def
get_layer_proto
(
self
,
name
):
for
layer
in
self
.
__model_config__
.
layers
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录