-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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 pairewise distance #26033
add pairewise distance #26033
Conversation
|
||
class TestPairwiseDistance(unittest.TestCase): | ||
def test_pairwise_distance(self): | ||
all_shape = [[100, 100], [4, 5, 6, 7]] |
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.
增加 broadcast 情况的单测
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.
增加其他 order 单测
python/paddle/nn/layer/distance.py
Outdated
|
||
""" | ||
|
||
def __init__(self, p=2., eps=1e-6, keepdim=False): |
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.
name参数
python/paddle/nn/layer/distance.py
Outdated
self.keepdim, 'epsilon', self.eps) | ||
|
||
sub = paddle.elementwise_sub(x, y) | ||
check_variable_and_dtype(sub, 'input', ['float32', 'float64'], 'p_norm') |
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和y进行check_variable_and_dtype, 不是sub进行check
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/nn/layer/distance.py
Outdated
'epsilon': self.eps, | ||
} | ||
out = self._helper.create_variable_for_type_inference( | ||
dtype=self._helper.input_dtype(sub)) |
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.
self._helper.input_dtype(x)
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/nn/layer/distance.py
Outdated
self.p = p | ||
self.eps = eps | ||
self.keepdim = keepdim | ||
check_type(self.p, 'porder', (float, int), 'p_norm') |
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.
p_norm -> PairwiseDistance
'PairwiseDistance') | ||
sub = paddle.elementwise_sub(x, y) | ||
|
||
helper = LayerHelper("p_norm", name=self.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.
p_norm->PairwiseDistance
'epsilon': self.eps, | ||
} | ||
out = helper.create_variable_for_type_inference( | ||
dtype=self._helper.input_dtype(x)) |
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.
_helper->helper
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
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
PR types
Others
PR changes
APIs
Describe
DOCS PREVIEW, DON'T MERGE