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

Implementation of Conditional Gradient Optimizer #469

Merged
merged 21 commits into from
Sep 20, 2019
Merged

Implementation of Conditional Gradient Optimizer #469

merged 21 commits into from
Sep 20, 2019

Conversation

pkan2
Copy link
Contributor

@pkan2 pkan2 commented Aug 31, 2019

Hello,

I have uploaded the implementation of Conditional Gradient optimizer into this directory. It is implementing the issue #468.

The contributors are Pengyu Kan and Vishnu sai rao suresh Lokhande, whose github name is lokhande-vishnu.

Sincerely,

Pengyu Kan

Copy link
Member

@Squadrick Squadrick left a comment

Choose a reason for hiding this comment

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

Could you rewrite the tests to be compatible with both graph and eager modes? Some of them seem to be graph only currently.

tensorflow_addons/optimizers/BUILD Outdated Show resolved Hide resolved
tensorflow_addons/optimizers/BUILD Outdated Show resolved Hide resolved
tensorflow_addons/optimizers/README.md Outdated Show resolved Hide resolved
tensorflow_addons/optimizers/README.md Outdated Show resolved Hide resolved
tensorflow_addons/optimizers/conditional_gradient.py Outdated Show resolved Hide resolved
tensorflow_addons/optimizers/conditional_gradient.py Outdated Show resolved Hide resolved
tensorflow_addons/optimizers/conditional_gradient.py Outdated Show resolved Hide resolved
tensorflow_addons/optimizers/conditional_gradient_test.py Outdated Show resolved Hide resolved
tensorflow_addons/optimizers/conditional_gradient_test.py Outdated Show resolved Hide resolved
tensorflow_addons/optimizers/conditional_gradient_test.py Outdated Show resolved Hide resolved
@Squadrick
Copy link
Member

Could you update the PR after formatting as mentioned here.

@pkan2
Copy link
Contributor Author

pkan2 commented Sep 2, 2019

Hi @Squadrick! Thank you for giving me the link!

It is really helpful. But I have some error on "clang-format" while running the "make code-format". So I just manually run the yapf to change the format. Wish that it can work. Thank you!

@facaiy
Copy link
Member

facaiy commented Sep 3, 2019

Hi, pkan2, did you try: bash tools/run_docker.sh -c 'make code-format' ? Note that it requires docker installed.

@facaiy
Copy link
Member

facaiy commented Sep 3, 2019

Seems that we forget to append a comma in the line end :-)

FAIL: buildifier found errors and/or warnings in above BUILD files.
buildifier suggested the following changes:
12c12
<         "weight_decay_optimizers.py"
---
>         "weight_decay_optimizers.py",
Please fix manually or run buildifier <file> to auto-fix.
Bazel configuration format check fails.

@pkan2
Copy link
Contributor Author

pkan2 commented Sep 3, 2019

Hello @Squadrick and @facaiy! Thank you for your feedbacks!

I think the reason for failing the GPU test is caused by similar issue in #347. I am trying to use the solution provided in the this issue into the "conditional_gradient_test.py" file to get rid of the issue of "tf.half" in "'ResourceScatterUpdate' OpKernel" for GPU device. And it seems that "tensorflow_addons.utils" does not have attribute of "'GpuSupportsHalfMatMulAndConv'" from the solution. So I will probably just delete this part and keep the rest from the solution.

Thank you!

Sincerely,

Pengyu Kan

@Squadrick
Copy link
Member

Yeah, that sounds good. We'll update the test once #347 is resolved. Could you add a TODO regarding this in the code?

@pkan2
Copy link
Contributor Author

pkan2 commented Sep 12, 2019

Hi @Squadrick! Thank you so much for the review! I have updated the file with the suggested changes. But for the variable name "lamda", I still have not decided on what name to choose, as "lambda" is a reserved key word in python. I will think about this point.

Thank you again!

@pkan2
Copy link
Contributor Author

pkan2 commented Sep 12, 2019

I have changed the variable name "lamda" into "Lambda".

@pkan2
Copy link
Contributor Author

pkan2 commented Sep 13, 2019

Hi @WindQAQ @facaiy ! Can you provide some reviews or suggestions on the modification for the code? Thanks!

Sincerely,

Pengyu Kan

@pkan2
Copy link
Contributor Author

pkan2 commented Sep 18, 2019

Hi! @WindQAQ @facaiy! Are there any more suggestions on the modifications I have to work on?

Thanks!

@facaiy
Copy link
Member

facaiy commented Sep 18, 2019

Sorry for the delay, @pkan2 . I'll take a look today. Thanks for ping me, Dheeraj :-)

Copy link
Member

@Squadrick Squadrick left a comment

Choose a reason for hiding this comment

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

If you annotate ConditionalGradientTest with test_utils.run_all_in_graph_and_eager_modes, you don't need to again separately annotate each test* method with test_utils.run_in_graph_and_eager_modes.

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.

Thank you, Pengyu! I'll take a full review tomorrow :-)

tensorflow_addons/optimizers/conditional_gradient.py Outdated Show resolved Hide resolved
Args:
learning_rate: A `Tensor` or a floating point value.
The learning rate.
Lambda: A `Tensor` or a floating point value. The constraint.
Copy link
Member

Choose a reason for hiding this comment

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

Can we use constraint here or other name? At least, lambda_ is accepted if we have no better choice :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion! It is just trying to keep the same letter used for expression in the formula by the paper. Can I choose "l_ambda" maybe? Otherwise, I can change into using "lambda_".

Thank you!

tensorflow_addons/optimizers/conditional_gradient.py Outdated Show resolved Hide resolved
tensorflow_addons/optimizers/conditional_gradient.py Outdated Show resolved Hide resolved
Squadrick
Squadrick previously approved these changes Sep 19, 2019
Copy link
Member

@Squadrick Squadrick left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution! We'll get this merged as soon as the test cases are done.

@pkan2
Copy link
Contributor Author

pkan2 commented Sep 19, 2019

@Squadrick @facaiy Thank you a lot!

@facaiy
Copy link
Member

facaiy commented Sep 20, 2019

Apologized that I'm busy this week than I expected. I'm fine to merge it if @Squadrick approved, and I'll recheck the PR later when I have time. 😄 thank all

@pkan2
Copy link
Contributor Author

pkan2 commented Sep 20, 2019

Hi @Squadrick @facaiy! I have changed the variable name of constraint into "lambda_". And I have updated the README file with adding co-contributor Vishnu Lokhande into it as maintainer too.

Thank you!

Copy link
Member

@Squadrick Squadrick left a comment

Choose a reason for hiding this comment

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

LGTM.

@Squadrick Squadrick merged commit 91c0846 into tensorflow:master Sep 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants