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 pairewise distance #26033

Merged
merged 5 commits into from
Aug 12, 2020
Merged

add pairewise distance #26033

merged 5 commits into from
Aug 12, 2020

Conversation

ZHUI
Copy link
Collaborator

@ZHUI ZHUI commented Aug 7, 2020

PR types

Others

PR changes

APIs

Describe

DOCS PREVIEW, DON'T MERGE


class TestPairwiseDistance(unittest.TestCase):
def test_pairwise_distance(self):
all_shape = [[100, 100], [4, 5, 6, 7]]
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

增加 broadcast 情况的单测

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

增加其他 order 单测


"""

def __init__(self, p=2., eps=1e-6, keepdim=False):
Copy link
Contributor

Choose a reason for hiding this comment

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

name参数

self.keepdim, 'epsilon', self.eps)

sub = paddle.elementwise_sub(x, y)
check_variable_and_dtype(sub, 'input', ['float32', 'float64'], 'p_norm')
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

'epsilon': self.eps,
}
out = self._helper.create_variable_for_type_inference(
dtype=self._helper.input_dtype(sub))
Copy link
Contributor

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)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

done

self.p = p
self.eps = eps
self.keepdim = keepdim
check_type(self.p, 'porder', (float, int), 'p_norm')
Copy link
Collaborator Author

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)
Copy link
Contributor

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))
Copy link
Contributor

Choose a reason for hiding this comment

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

_helper->helper

Copy link
Contributor

@wawltor wawltor left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@yaoxuefeng6 yaoxuefeng6 left a comment

Choose a reason for hiding this comment

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

LGTM

@wawltor wawltor merged commit 361363c into PaddlePaddle:develop Aug 12, 2020
@ZHUI ZHUI deleted the pairwisedistance branch September 14, 2020 09:32
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.

None yet

3 participants