Skip to content

Commit

Permalink
fix bug of grad
Browse files Browse the repository at this point in the history
  • Loading branch information
longranger2 committed May 30, 2023
1 parent b8a141f commit 0444f78
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions python/paddle/fluid/tests/unittests/test_lerp_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,16 @@ def init_wshape(self):
self.wshape = [1]

def init_grad(self, w):
self.x_grad = np.ones(self.xshape) * (1 - w)
self.y_grad = np.ones(self.xshape) * w
self.x_grad = (
np.ones(self.xshape)
* (1 - w)
/ (np.prod(self.xshape) / np.prod(self.wshape))
)
self.y_grad = (
np.ones(self.yshape)
* w
/ (np.prod(self.yshape) / np.prod(self.wshape))
)

def test_check_output(self):
place = core.CUDAPlace(0)
Expand Down

0 comments on commit 0444f78

Please sign in to comment.