Skip to content
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 the bug that parameters are note transposed. #387

Merged
merged 2 commits into from
Oct 18, 2017

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 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 train.py ```。程序第一次运行会检测用户缓存文件夹中是否包含imikolov数据集,如果未包含,则自动下载。运行过程中,每100个iteration会打印模型训练信息,主要包含训练损失和测试损失,每个pass会保存一次模型。

## 预测阶段
预测时,直接运行``` 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.

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

@Yancey1989 Yancey1989 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.

None yet

2 participants