-
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 the L2 distance layer. #5736
Conversation
97bae9a
to
122f5bf
Compare
3c57ac7
to
6806dbe
Compare
6806dbe
to
4772b78
Compare
@layer_support() | ||
def l2_distance_layer(x, y, name=None, layer_attr=None): | ||
""" | ||
This layer calculate and return the Euclidean distance between two 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.
...calculates...returns...
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.
Layer( | ||
name=name, | ||
type=LayerType.L2_DISTANCE, | ||
inputs=[x.name, x.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.
y.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.
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') |
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.
首字母大写,dim单词不要简写
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.
7b557bc
to
29fc94b
Compare
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
fixes #5739