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

fix bn grad compute when x.stop_gradient=True #34102

Merged
merged 4 commits into from
Jul 15, 2021

Conversation

ceci3
Copy link
Contributor

@ceci3 ceci3 commented Jul 12, 2021

PR types

Bug fixes

PR changes

OPs

Describe

fix bn grad compute when x.stop_gradient=True

import paddle
paddle.enable_static()

x = paddle.static.data(shape=[4,3, 10, 10], dtype='float32', name='x')
x.stop_gradient = True

bn = paddle.nn.BatchNorm2D(3)
y = bn(x)

avg_cost = paddle.mean(y)
sgd_optimizer = paddle.optimizer.SGD(learning_rate=0.001)
sgd_optimizer.minimize(avg_cost)
print(paddle.static.default_main_program())```

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@ceci3 ceci3 requested a review from Aurelius84 July 13, 2021 07:01
wanghaoshuang
wanghaoshuang previously approved these changes Jul 13, 2021
Copy link
Contributor

@qingqing01 qingqing01 left a comment

Choose a reason for hiding this comment

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

Need to add UT.

Copy link
Contributor

@zhiqiu zhiqiu left a comment

Choose a reason for hiding this comment

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

LGTM for ShareDataWith

Copy link
Contributor

@zhangting2020 zhangting2020 left a comment

Choose a reason for hiding this comment

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

LGTM for skip_check_grad_ci

@Aurelius84 Aurelius84 merged commit 637f27c into PaddlePaddle:develop Jul 15, 2021
@ceci3 ceci3 deleted the fix_bn branch August 24, 2021 07:13
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.

6 participants