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

[Metrics] class based embedding similarity + tests #3358

Merged
merged 16 commits into from
Sep 11, 2020

Conversation

SkafteNicki
Copy link
Member

What does this PR do?

PR #3349 added a new functional metric embedding_similarity. This PR just follows up and adds a class based interface + adds tests against sklearn

Before submitting

  • Was this discussed/approved via a Github issue? (no need for typos and docs improvements)
  • Did you read the contributor guideline, Pull Request section?
  • Did you make sure your PR does only one thing, instead of bundling different changes together? Otherwise, we ask you to create a separate PR for every change.
  • Did you make sure to update the documentation with your changes?
  • Did you write any new necessary tests?
  • Did you verify new and existing tests pass locally with your changes?
  • If you made a notable change (that affects users), did you update the CHANGELOG?

PR review

Anyone in the community is free to review the PR once the tests have passed.
If we didn't discuss your PR in Github issues there's a high chance it will not be merged.

Did you have fun?

Make sure you had fun coding 🙃

@mergify mergify bot requested a review from a team September 5, 2020 10:10
@SkafteNicki SkafteNicki mentioned this pull request Sep 5, 2020
docs/source/metrics.rst Outdated Show resolved Hide resolved
@mergify mergify bot requested a review from a team September 6, 2020 01:07
docs/source/metrics.rst Outdated Show resolved Hide resolved
@mergify mergify bot requested a review from a team September 6, 2020 02:19
@codecov
Copy link

codecov bot commented Sep 6, 2020

Codecov Report

Merging #3358 into master will decrease coverage by 13%.
The diff coverage is 62%.

@@           Coverage Diff            @@
##           master   #3358     +/-   ##
========================================
- Coverage      90%     78%    -13%     
========================================
  Files          93     111     +18     
  Lines        8188   10286   +2098     
========================================
+ Hits         7397    7990    +593     
- Misses        791    2296   +1505     

Copy link
Contributor

@awaelchli awaelchli left a comment

Choose a reason for hiding this comment

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

lgtm, just some whitespace that needs to be fixed for proper display in html

pytorch_lightning/metrics/self_supervised.py Outdated Show resolved Hide resolved
pytorch_lightning/metrics/self_supervised.py Outdated Show resolved Hide resolved
@mergify mergify bot requested a review from a team September 6, 2020 03:45
@mergify mergify bot requested a review from a team September 6, 2020 16:52
Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>
@pep8speaks
Copy link

pep8speaks commented Sep 7, 2020

Hello @SkafteNicki! Thanks for updating this PR.

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2020-09-11 06:10:39 UTC

Co-authored-by: Rohit Gupta <rohitgr1998@gmail.com>
@mergify mergify bot requested a review from a team September 7, 2020 05:39
@justusschock justusschock self-requested a review September 7, 2020 09:21
@mergify mergify bot requested a review from a team September 7, 2020 09:21
@@ -287,3 +287,6 @@ def output_convert(self, data: Any, output: Any):
def ddp_sync(self, data: Any, output: Any):
return apply_to_collection(output, torch.Tensor, sync_ddp_if_available,
self.reduce_group, self.reduce_op)


__all__ = ["Metric", "TensorMetric", "NumpyMetric"]
Copy link
Member

Choose a reason for hiding this comment

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

this is not a very common place for __all__

Copy link
Contributor

Choose a reason for hiding this comment

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

codefactor also complains about this, not sure why. I think it should be fine though.

Copy link
Member

Choose a reason for hiding this comment

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

the point is that it is very related to importing from packages when you do not want to import all functions
https://stackoverflow.com/questions/44834/can-someone-explain-all-in-python

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that it is not a common place for __all__, normally I would put it at the top of the file, but then codefactor complains about it. But I can move it to the top if that is better.

Copy link
Member

Choose a reason for hiding this comment

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

yes, it is not very common to have it in other files than __init__ so was there a reason to move it from the init?

Copy link
Member Author

Choose a reason for hiding this comment

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

I was changed due to a comment for justus at some point, but lets change it back since it is very uncommon practise

pytorch_lightning/metrics/self_supervised.py Show resolved Hide resolved
pytorch_lightning/metrics/self_supervised.py Outdated Show resolved Hide resolved
pytorch_lightning/metrics/self_supervised.py Show resolved Hide resolved
@Borda Borda added the ready PRs ready to be merged label Sep 11, 2020
@Borda Borda merged commit 93cf6d0 into Lightning-AI:master Sep 11, 2020
@SkafteNicki SkafteNicki deleted the metrics/semi_supervised branch September 11, 2020 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready PRs ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants