Skip to content

Conversation

@PyExtreme
Copy link
Contributor

@PyExtreme PyExtreme commented Sep 16, 2019

Fix #509

I have added the documentation for the CorrelationCost function and also made the correlation_cost as private.

I am new to open source and this is my first contribution to the community. I would appreciate any reviews.

Thanks

@googlebot

This comment has been minimized.

@PyExtreme

This comment has been minimized.

@PyExtreme PyExtreme reopened this Sep 16, 2019
@PyExtreme
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

FlowNet Learning Optical Flow with Convolutional Networks (Fischer et al.) r
Following are the parameters it takes:
input_a: A `Tensor` of the format specified by `data_format`.
Copy link
Member

Choose a reason for hiding this comment

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

Hi @PyExtreme! Thanks for the contribution! Would you mind adapting this doc string parameters to match the __init__ args that are used to construct this layer. For example you'll notice input_a and input_b are passed in on the Layers __call__ method. There needs to be some slight changes since this doc string is for the Layer's instantiation.

data_format: Specifies the data format.
Possible values are:
"NHWC" float [batch, height, width, channels]
Copy link
Member

Choose a reason for hiding this comment

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

Also you'll want to adapt this to the keras style of channel_first or channel_last

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure @seanpmorgan , will make these changes.

Thanks for the help.

@WindQAQ WindQAQ self-requested a review September 16, 2019 16:23
Copy link
Member

@WindQAQ WindQAQ left a comment

Choose a reason for hiding this comment

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

For the documentation of _correlation_cost, I wonder if we could directly assign it from the cpp op. Maybe _correlation_cost.__doc__ = op.__doc__ works. I'm not so familiar with SWIG, @facaiy is it possible to do this?

@PyExtreme
Copy link
Contributor Author

For the documentation of _correlation_cost, I wonder if we could directly assign it from the cpp op. Maybe _correlation_cost.__doc__ = op.__doc__ works. I'm not so familiar with SWIG, @facaiy is it possible to do this?

Hi @WindQAQ , Could you please have a look at my changes? Is there anything more required?

@fsx950223
Copy link
Member

Could I review this pull request? @WindQAQ @facaiy @seanpmorgan

@seanpmorgan
Copy link
Member

Could I review this pull request? @WindQAQ @facaiy @seanpmorgan

Absolutely! We're always looking for more reviewers (should probably add that to CONTRIBUTING.md). It still requires a maintainer to merge but its super helpful.

with tf.name_scope(name or "correlation_cost"):
op_call = _correlation_cost_op_so.correlation_cost
with tf.name_scope(name or "_correlation_cost"):
op_call = _correlation_cost_op_so._correlation_cost
Copy link
Member

@fsx950223 fsx950223 Sep 17, 2019

Choose a reason for hiding this comment

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

It seems _correlation_cost_op_so has no attribute '_correlation_cost'. Have you test the code on the local environment? And I believe correlation_cost is more suitable for name scope.

from tensorflow_addons.layers.optical_flow import correlation_cost, CorrelationCost

The function name correlation_cost should be changed to _correlation_cost.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @fsx950223 , we won't be able to import it still. I will change the name scope but I am not sure how to go with the test file so as to run the test.
One way is to make correlation_cost nested in some other function and calling the outer function. But this will not be private, however, easy to import in test.
Second way is to add _correlation_cost function in the test file also.
Alternatively, I think, if somehow, correlation_cost function can be added as a private function to the CorrelationCost class and then we can call call it.

@fsx950223
Copy link
Member

fsx950223 commented Sep 17, 2019

Maybe you should rewrite the test case too.

@seanpmorgan
Copy link
Member

Maybe you should rewrite test case too.

Could you be more specific in your reviews and describe why you think this should be done. Also this PR should really stick to the docstring as it's addressing a posted issue.

@fsx950223
Copy link
Member

Maybe you should rewrite test case too.

Could you be more specific in your reviews and describe why you think this should be done. Also this PR should really stick to the docstring as it's addressing a posted issue.

from tensorflow_addons.layers.optical_flow import correlation_cost, CorrelationCost

The function name correlation_cost should be changed to _correlation_cost. And sometimes test case is an example for developers. It should not use private functions.

@seanpmorgan
Copy link
Member

For the documentation of _correlation_cost, I wonder if we could directly assign it from the cpp op. Maybe _correlation_cost.__doc__ = op.__doc__ works. I'm not so familiar with SWIG, @facaiy is it possible to do this?

Unfortunately looks like no (at least for the way we're currently doing it):
https://colab.research.google.com/drive/1g9XmQbT-gDuAUyVkQSqgFLZVCEvEmSIJ

@googlebot

This comment has been minimized.

@seanpmorgan
Copy link
Member

seanpmorgan commented Sep 17, 2019

Hi @PyExtreme I've made a small commit on your branch just because this is blocking a few things (and I should have taken care of this a week or two ago when Yan pointed it out). Can you please review and let me know if it makes sense.

@fsx950223 Thank you very much for your review. After your clarification I understand. I agree on the namespacing. As far as not testing the private method I think that's a good idea but not essential. Renaming the op should be enough to indicate to users that it's discouraged (but not impossible) to use that Op by itself. Happy to accept a PR which modifies those test cases separately though.

EDIT ----
Also don't worry about the CLA we can override it.

@WindQAQ
Copy link
Member

WindQAQ commented Sep 17, 2019

For the documentation of _correlation_cost, I wonder if we could directly assign it from the cpp op. Maybe _correlation_cost.__doc__ = op.__doc__ works. I'm not so familiar with SWIG, @facaiy is it possible to do this?

Unfortunately looks like no (at least for the way we're currently doing it):
https://colab.research.google.com/drive/1g9XmQbT-gDuAUyVkQSqgFLZVCEvEmSIJ

Alright, that's fine. Thanks for the investigation, Sean 😃

@facaiy
Copy link
Member

facaiy commented Sep 18, 2019

@seanpmorgan Happy to accept a PR which modifies those test cases separately though.

+1

@WindQAQ Maybe _correlation_cost.doc = op.doc works.

At least in tensorflow core repository, we always add document manually. Good question, I'll look into it if I have time :-)

@PyExtreme Welcome, PyExtreme, please address Sean's comments about docstring, thank you 😄

@PyExtreme
Copy link
Contributor Author

@seanpmorgan , I will look into it surely and let you know.

facaiy
facaiy previously approved these changes Sep 19, 2019
Copy link
Member

@facaiy facaiy left a comment

Choose a reason for hiding this comment

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

Looks good for me. I'd like to merge it if there is no opposition. Thank @PyExtreme

@facaiy
Copy link
Member

facaiy commented Sep 19, 2019

@fsx950223 Hi, I filed an issue #526 for test cases of correlation cost. Let's fix them in the next PR, what do you think :-)

# Conflicts:
#	tensorflow_addons/layers/optical_flow_test.py
@seanpmorgan seanpmorgan merged commit 0e9ba61 into tensorflow:master Sep 19, 2019
@seanpmorgan
Copy link
Member

Thanks @PyExtreme and everyone else! Merging this in as its blocking a couple of things, but please review and let us know in a separate PR/issue if there are problems

facaiy pushed a commit to facaiy/addons that referenced this pull request Sep 20, 2019
* Add Docstring CorrelationCost
* Add CorrelationCost Documentation
* Small reformat
seanpmorgan pushed a commit that referenced this pull request Sep 20, 2019
* Add docstring correlation cost (#514)

* Add Docstring CorrelationCost
* Add CorrelationCost Documentation
* Small reformat

* BLD: built on 2.0.0-rc1

* DOC: doc for 0.5.1

* Fix optical_flow test case (#527)

* typo fix (#523)

* CLN: fix file permission 755 in #527

* CLN: use public api, tf.keras
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add docstring for Correlation cost layer

7 participants