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

Calculating gradients for partial graph #7269

Merged
merged 3 commits into from
Jan 10, 2018

Conversation

emailweixu
Copy link
Collaborator

Added backward.calc_gradient to backpropagate gradient from given targets to inputs.

return op_path


def calc_gradient(targets, inputs, target_gradients=None, no_grad_set=None):
Copy link
Collaborator

@JiayiFeng JiayiFeng Jan 8, 2018

Choose a reason for hiding this comment

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

I have a few questions about the calc_gradient:

  1. It seems that this API appends partial backward to calculate gradients of targets to inputs. Can this API be used by users directly? And when will users use it?
  2. Here are some special handlings(like _rename_grad_) to make sure this API can be invoked for multiple times. However, in each invoking the program itself will be changed(some backward ops are appended). So during the second invoke, the backward part generated in the first time is still in the program and is regarded as forwarding part. Is this reasonable?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. Yes. Some algorithm have its own way of calculating gradients. One example is Learning to learn by gradient descent by gradient descent.
  2. Yes. This happens in cases where gradients from different parts needs to be combined in some way to calculate the final result.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Got it!

xuwei06 added 3 commits January 9, 2018 18:21
Added backward.calc_gradient to backpropagate gradient from given targets to inputs.
Copy link
Collaborator

@JiayiFeng JiayiFeng left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@JiayiFeng JiayiFeng merged commit df92776 into PaddlePaddle:develop Jan 10, 2018
@emailweixu emailweixu deleted the calc_gradient branch March 16, 2018 23:03
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.

2 participants