-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
Conversation
luotao1
commented
Oct 17, 2017
- solve part2 of Add sequence_pool op #4186
- simplify test_pool_py
- add comments for different pooling strategies. add SQRT/LAST/FIRST strategy for Seqpool #4788 (review)
paddle/operators/sequence_pool_op.h
Outdated
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); |
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 update code, the Slice
remove the template T: /~https://github.com/PaddlePaddle/Paddle/blob/develop/paddle/framework/tensor.h#L124
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
paddle/operators/sequence_pool_op.h
Outdated
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); |
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.
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.
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. 在反向中采用maxCoeff函数,获得每列中的第一个最大值。
考虑到inference的效率,保持前向不变,maxCoeff加在反向中。
目前实现的版本性能上还有待优化,等之后的PR修复。