Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Fix SliceLikeBackward #14209

Merged
merged 1 commit into from
Feb 20, 2019
Merged

Conversation

ptrendx
Copy link
Member

@ptrendx ptrendx commented Feb 19, 2019

Description

This PR fixes a bug in slice_like operator, where, if the first input is constant, the backward pass of this operator would not fill the gradient to the second input with zeros, instead passing random memory contents.

Checklist

Essentials

Please feel free to remove inapplicable items for your PR.

  • Changes are complete (i.e. I finished coding on this PR)
  • To the my best knowledge, examples are either not affected by this change, or have been fixed to be compatible with this change

Changes

  • Moved the handling of the second input before the early exit for the first input

Comments

a = F.slice_like(anchors, x * 0, axes=(2, 3))

where the work around was to multiply the second input by 0 (effectively zeroing the gradient). With this PR, this work around is not needed anymore (and it is also not fully safe - NaNs and Infs in the memory returned from SliceLikeBackward would produce NaNs when multiplied by 0 and so would still break the training). @zhreshold FYI

@eric-haibin-lin

Copy link
Member

@zhreshold zhreshold left a comment

Choose a reason for hiding this comment

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

nice catch!

Copy link
Member

@eric-haibin-lin eric-haibin-lin left a comment

Choose a reason for hiding this comment

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

Nice catch

@eric-haibin-lin eric-haibin-lin merged commit f9c436b into apache:master Feb 20, 2019
jessr92 pushed a commit to jessr92/incubator-mxnet that referenced this pull request Feb 28, 2019
jessr92 pushed a commit to jessr92/incubator-mxnet that referenced this pull request Feb 28, 2019
jessr92 pushed a commit to jessr92/incubator-mxnet that referenced this pull request Feb 28, 2019
drivanov pushed a commit to drivanov/incubator-mxnet that referenced this pull request Mar 4, 2019
vdantu pushed a commit to vdantu/incubator-mxnet that referenced this pull request Mar 31, 2019
haohuanw pushed a commit to haohuanw/incubator-mxnet that referenced this pull request Jun 23, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants