dcslin edited a comment on issue #639: added support for matmul 3d 4d
URL: https://github.com/apache/singa/pull/639#issuecomment-605793210
 
 
   > is matmul different to tensordot?
   > why not call tensordot to implement it?
   
   Batch matmul could not be implemented by tensordot, as batch matmul is not 
really tensor dot.
   Batch matmul could be illustrated by einsum:
   ``` python
   >>> x1.shape
   (2, 3, 4, 5)
   >>> x2.shape
   (2, 3, 5, 6)
   >>> np.testing.assert_almost_equal(np.matmul(x1,x2), 
np.einsum('ijkl,ijlm->ijkm',x1,x2))
   # output is (2,3,4,6)
   ```
   
   
   Boardcasting matmul could be implemented by tensordot:
   ```
   >>> x1.shape
   (2, 3, 4, 5)
   >>> x3.shape
   (5, 6)
   >>> np.testing.assert_almost_equal(np.matmul(x1,x3), 
np.tensordot(x1,x3,axes=([3],[0])))
   # output is (2,3,4,6)
   ```

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to