-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 sequence conv layer" #5117
"add sequence conv layer" #5117
Conversation
python/paddle/v2/framework/layers.py
Outdated
@@ -276,6 +276,30 @@ def pool2d(input, | |||
return pool_out | |||
|
|||
|
|||
def sequence_conv_pool(input, |
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.
_create_op_func_('sequence_conv_pool')
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.
Here we need to check validation of input arguments and need to create filter parameter based on two arguments.
python/paddle/v2/framework/layers.py
Outdated
attr=helper.param_attr, shape=filter_shape, dtype=dtype) | ||
pre_bias = helper.create_tmp_variable(dtype) | ||
|
||
input.set_lod(lod) |
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.
Where is the lod
from?
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.
removed.
python/paddle/v2/framework/layers.py
Outdated
helper.append_op( | ||
type='sequence_conv', | ||
inputs={ | ||
'X': input, |
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.
"X": [input]
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.
python/paddle/v2/framework/layers.py
Outdated
@@ -204,6 +218,47 @@ def square_error_cost(input, label, **kwargs): | |||
return square_out | |||
|
|||
|
|||
def conv1d(input, |
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.
Maybe sequence_conv
is a better name?
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.
Rename conv1d
to sequence_conv
after discuss with @Canpio offline, since this function's behavior is different with conv2d
, conv3d
, fixed.
python/paddle/v2/framework/layers.py
Outdated
# FIXME(dzh) : want to unify the argument of python layer | ||
# function. So we ignore some unecessary attributes | ||
|
||
ENUM_POOL_TYPE = ["max", "avg", "sqrt", "last", "first"] |
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.
Initialize ENUM_POOL_TYPE
as a set to make the following if pool_type not in ENUM_POOL_TYPE:
faster.
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.
python/paddle/v2/framework/layers.py
Outdated
|
||
helper.append_op( | ||
type="sequence_pool", | ||
inputs={"X": input}, |
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.
'X': [input]
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.
python/paddle/v2/framework/layers.py
Outdated
type="sequence_pool", | ||
inputs={"X": input}, | ||
outputs={"Out": pool_out}, | ||
attrs={"strategy": pool_type, }) |
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.
remove ,
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.
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.
LGTM.
Add sequence conv layer. This PR depends on #4814.