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 python wrapper for sequence_pool #6787

Merged
merged 4 commits into from
Dec 22, 2017
Merged

add python wrapper for sequence_pool #6787

merged 4 commits into from
Dec 22, 2017

Conversation

luotao1
Copy link
Contributor

@luotao1 luotao1 commented Dec 20, 2017

fix #6777
The generated sequence_pool website is :
image
image
image

@luotao1 luotao1 requested a review from pkuyym December 20, 2017 08:55
@luotao1
Copy link
Contributor Author

luotao1 commented Dec 22, 2017

The generated sequence_first_step website is :
image
image
The generated sequence_last_step website is :
image
image

avg_x = fluid.layers.sequence_pool(input=x, pool_type='average')
sum_x = fluid.layers.sequence_pool(input=x, pool_type='sum')
sqrt_x = fluid.layers.sequence_pool(input=x, pool_type='sqrt')
max_x = fluid.layers.sequence_pool(input=x, pool_type='max')
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it necessary to limit the type in (average/sum/sqrt/max)?
If so, I think it's better to add a check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If I limit the type in (average/sum/sqrt/max), then sequence_first_step should not be

def sequence_first_step(input, **kwargs):
    return sequence_pool(input=input, pool_type="first")

It should be

def sequence_first_step(input, **kwargs):
    helper = LayerHelper('sequence_pool', input=input, **kwargs)
    dtype = helper.input_dtype()
    pool_out = helper.create_tmp_variable(dtype)
    max_index = helper.create_tmp_variable(dtype)

    helper.append_op(
        type="sequence_pool",
        inputs={"X": input},
        outputs={"Out": pool_out,
                 "MaxIndex": max_index},
        attrs={"pooltype": "first"})

    return pool_out

but max_index = helper.create_tmp_variable(dtype) could not be removed. If we want to remove it, we should add an single sequence_max_op.cc

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, thanks.

Copy link
Contributor

@pkuyym pkuyym left a comment

Choose a reason for hiding this comment

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

Great Job

@luotao1 luotao1 merged commit fc5c432 into PaddlePaddle:develop Dec 22, 2017
@luotao1 luotao1 deleted the seq_pool_doc branch December 22, 2017 07:03
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.

Need add python wrapper for sequence_pool
2 participants