-
Notifications
You must be signed in to change notification settings - Fork 617
Add docstring correlation cost #514
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 docstring correlation cost #514
Conversation
…d-docstring-correlation_cost
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@googlebot I signed it! |
|
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`. |
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.
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] |
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.
Also you'll want to adapt this to the keras style of channel_first or channel_last
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.
Sure @seanpmorgan , will make these changes.
Thanks for the help.
WindQAQ
left a comment
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.
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? |
|
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 |
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.
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.
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.
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.
|
Maybe you should rewrite the 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. |
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. |
Unfortunately looks like no (at least for the way we're currently doing it): |
This comment has been minimized.
This comment has been minimized.
|
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 ---- |
Alright, that's fine. Thanks for the investigation, Sean 😃 |
+1
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 😄 |
|
@seanpmorgan , I will look into it surely and let you know. |
facaiy
left a comment
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.
Looks good for me. I'd like to merge it if there is no opposition. Thank @PyExtreme
|
@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
|
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 |
* Add Docstring CorrelationCost * Add CorrelationCost Documentation * Small reformat
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