Skip to content

Conversation

lcy-seso
Copy link
Collaborator

@lcy-seso lcy-seso commented Oct 18, 2017

fix the bug that when loading the parameter trained by hsigmoid and NCE layer in inferring, the parameters are not transposed.

@lcy-seso lcy-seso requested a review from Yancey0623 October 18, 2017 05:25
@lcy-seso lcy-seso force-pushed the fix_transpose_in_hsigmoid_nce branch 4 times, most recently from 645f237 to 249aa15 Compare October 18, 2017 05:37
@lcy-seso lcy-seso force-pushed the fix_transpose_in_hsigmoid_nce branch from 249aa15 to f4cdd71 Compare October 18, 2017 05:44

## 预测阶段
预测时,直接运行``` python infer.py ```程序会首先load模型,然后按照batch方式进行预测,并打印预测结果。预测阶段最重要的就是根据概率得到编码路径,然后遍历路径获取最终的预测类别,这部分逻辑如下:
预测时,在命令行运行 `infer.py --model_path XX`,通过`model_path`指定训练好的模型所在的路径。程序会首先load模型,然后按照batch方式进行预测,并打印预测结果。预测阶段最重要的就是根据概率得到编码路径,然后遍历路径获取最终的预测类别,这部分逻辑如下:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python infer.py --model_path ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

input=hidden_layer,
param_attr=paddle.attr.Param(name="nce_w"))
```
1. 在命令行运行 `infer.py --model_path XX`,通过`model_path`指定训练好的模型所在的路径。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python infer.py --model_path ...

Copy link
Collaborator Author

@lcy-seso lcy-seso Oct 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The develop branch has been updated. If the parameter num_classes is not set, it is automatically determined by the size of the inputlabel https://github.com/PaddlePaddle/Paddle/blob/develop/python/paddle/trainer_config_helpers/layers.py#L2344.

This may cause the problem if the size of label is not correctly set (If the size of label is not correctly set, PaddlePaddle will not throw an error.), maybe explicitly set the num_classes is better.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return paddle.layer.hsigmoid(
input=hidden_layer,
label=target_word,
num_classes=dict_size,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@lcy-seso lcy-seso force-pushed the fix_transpose_in_hsigmoid_nce branch 2 times, most recently from b52c5c1 to 6d39971 Compare October 18, 2017 06:27
@lcy-seso lcy-seso force-pushed the fix_transpose_in_hsigmoid_nce branch from 6d39971 to 406761e Compare October 18, 2017 06:32
Copy link
Contributor

@Yancey0623 Yancey0623 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@lcy-seso lcy-seso merged commit 13ff59e into PaddlePaddle:develop Oct 18, 2017
@lcy-seso lcy-seso deleted the fix_transpose_in_hsigmoid_nce branch November 14, 2017 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants