-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix bugs of parsing network topology in text generation task #2384
fix bugs of parsing network topology in text generation task #2384
Conversation
Do not approve. |
doc/api/v2/config/layer.rst
Outdated
Miscs | ||
===== | ||
|
||
dropout_layer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
v2 api中默认后面不加layer,dropout_layer后面为什么要加呢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
已经修改。将 drop 从 network 下移动到 layer 下,潜在会影响一些旧的配置。
f6a2934
to
0e16aed
Compare
0e16aed
to
9146e7b
Compare
9146e7b
to
862b72b
Compare
862b72b
to
692d251
Compare
Please ignore "TeamCity build failed", see: #2401 |
@helinwang I get it. Thank you. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fix a bug of parsing evaluator.
@@ -235,11 +235,10 @@ def __trim_submodel__(old_submodel, layer_names, input_layer_names, | |||
def parse_network(output_layers, extra_layers=None): | |||
if not isinstance(output_layers, collections.Sequence): | |||
output_layers = [output_layers] | |||
if extra_layers is not None and not isinstance(extra_layers, | |||
collections.Sequence): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Topology 的构造函数中会对 extra_layers 的类型进行检查
- 检查的过程中,如果传入的extra_layer 不是 python list,会转化为 list
https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/v2/topology.py#L43 - Topology 构造函数调用
parse_network
走到这里时,如果指定了extra_layer
,extra_layer
是一个 python list - 这两个条件一个为
True
,一个为False
与之后,会走到else
分枝将 extra_layer 清空
d1e6e77
to
1e21259
Compare
ff71f9d
to
35332a2
Compare
python/paddle/v2/layer.py
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- In text generation, the
outlink
to save the generated word indices is aDataLayer
https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/trainer/config_parser.py#L427 defined in theRecurrentLayerGroupEnd
function. - If this
DataLayer
is not excluded from inputs of the network, an error occurs during data feeding. - This
DataLayer
is sure to be the output in text generation, so I add this statement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to add a comment. Otherwise it's very hard to understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
python/paddle/v2/topology.py
Outdated
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when is input_layer not a data_layer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a mistake. I have fixed this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
follow comments.
python/paddle/v2/layer.py
Outdated
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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- In text generation, the
outlink
to save the generated word indices is aDataLayer
https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/trainer/config_parser.py#L427 defined in theRecurrentLayerGroupEnd
function. - If this
DataLayer
is not excluded from inputs of the network, an error occurs during data feeding. - This
DataLayer
is sure to be the output in text generation, so I add this statement.
python/paddle/v2/topology.py
Outdated
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a mistake. I have fixed this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
48ad842
to
892b1f9
Compare
fix #2349. fix #2385
eos_layer
is not trimmed as a used layer in text generation.dropout_layer
frompaddle.network
topaddle.layer
StaticInput
andGeneratedInput
. Currently,StaticInputV2
andGeneratedInputV2
are not available anymore, useStaticInput
andGeneratedInput
instead.