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 the L2 distance layer. #5736

Merged
merged 5 commits into from
Nov 19, 2017
Merged

Conversation

lcy-seso
Copy link
Contributor

@lcy-seso lcy-seso commented Nov 17, 2017

fixes #5739

@lcy-seso lcy-seso force-pushed the l2_distance branch 2 times, most recently from 97bae9a to 122f5bf Compare November 17, 2017 08:58
@lcy-seso lcy-seso force-pushed the l2_distance branch 3 times, most recently from 3c57ac7 to 6806dbe Compare November 17, 2017 09:10
@layer_support()
def l2_distance_layer(x, y, name=None, layer_attr=None):
"""
This layer calculate and return the Euclidean distance between two input
Copy link
Contributor

Choose a reason for hiding this comment

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

...calculates...returns...

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.

Layer(
name=name,
type=LayerType.L2_DISTANCE,
inputs=[x.name, x.name],
Copy link
Contributor

Choose a reason for hiding this comment

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

y.name

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, thank you.

config_assert(len(self.inputs) == 2, 'CosSimLayer must have 2 inputs')
config_assert(
self.get_input_layer(0).size == self.get_input_layer(1).size,
'inputs of CosSimLayer must have same dim')
Copy link
Contributor

Choose a reason for hiding this comment

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

首字母大写,dim单词不要简写

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.

Copy link
Contributor

@guoshengCS guoshengCS 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 c6ec26d into PaddlePaddle:develop Nov 19, 2017
@lcy-seso lcy-seso deleted the l2_distance branch November 19, 2017 10:20
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.

Add a L2 norm distance layer.
3 participants