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

add Max strategy for sequence_pool op #4864

Merged
merged 7 commits into from
Oct 27, 2017
Merged

add Max strategy for sequence_pool op #4864

merged 7 commits into from
Oct 27, 2017

Conversation

luotao1
Copy link
Contributor

@luotao1 luotao1 commented Oct 17, 2017

case MAX: {
auto in_t = in->Slice<T>(static_cast<int>(lod[i]),
static_cast<int>(lod[i + 1]));
auto out_t = out->Slice<T>(i, i + 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to update code, the Slice remove the template T: https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/framework/tensor.h#L124

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

auto ones = in_g_e.constant(1);
auto zeros = in_g_e.constant(0);
in_g_e.device(place) =
out_g_e.broadcast(bcast) * equals.select(ones, zeros);
Copy link
Contributor

Choose a reason for hiding this comment

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

It's better to keep the same way with the MaxSeqPool in the old framework, which records the max indexes in the forward and uses them in the backward. Since there may be multiple maximum values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. 在反向中采用maxCoeff函数,获得每列中的第一个最大值。
考虑到inference的效率,保持前向不变,maxCoeff加在反向中。
目前实现的版本性能上还有待优化,等之后的PR修复。

@luotao1 luotao1 merged commit 92c3279 into PaddlePaddle:develop Oct 27, 2017
@luotao1 luotao1 deleted the maxseq branch October 27, 2017 07:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants