hanke580 opened a new pull request #19187:
URL: https://github.com/apache/incubator-mxnet/pull/19187


   * Fix tensordot
   
   ## Description ##
   Operator tensordot running wrong when the gradient is attached with "add" 
like
   
   ~~~
   from mxnet import np, npx
   npx.set_np()
   npx.random.seed(123)
   from mxnet import autograd
   
   a = np.random.normal(0,1,(3,2)).astype(np.float32)
   b = np.random.normal(0,1,(2)).astype(np.float32)
   a.attach_grad("add")
   b.attach_grad()
   
   # the initialization of a won't succeed
   a.grad[:] = np.ones((3,2)).astype(np.float32)
   a.grad
   
   with autograd.record():
        m = np.tensordot(a,b,[[1],[0]])
        m.backward()
   
   ~~~
   Also, if you redefine `m = np.random.normal(0,1,(3,2)).astype(np.float32)`, 
m will have the gradient of a.
   
   Now the issue has been fixed and all tests covered.
   
   
   
   ## Checklist ##
   ### Essentials ###
   - [ ] PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], 
[FEATURE], [DOC], etc)
   - [ ] Changes are complete (i.e. I finished coding on this PR)
   - [ ] All changes have test coverage
   - [ ] Code is well-documented
   
   ### Changes ###
   - [ ] Feature1, tests, (and when applicable, API doc)
   - [ ] Feature2, tests, (and when applicable, API doc)
   
   ## Comments ##
   - If this change is a backward incompatible change, why must this change be 
made.
   - Interesting edge cases to note here
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to