TransWikia.com

The Math behind a tesorflow.tensordot()

Stack Overflow Asked by Harsh Dhamecha on February 1, 2021

I have been trying to understand the math behind a tensorflow.tensordot(), mainly axes parameter. I have tried some code.

My code

A = tf.constant([[32, 83, 5],
             [17, 23, 10],
             [75, 39, 52]])
B = tf.constant([[28, 57, 20],
             [91, 10, 95],
             [37, 13, 45]])
dot_AB = tf.tensordot(A, B, axes = 1)
print(f'Dot product is n {dot_AB.numpy()}')

Output

Dot product is 
[[8634 2719 8750]
 [2939 1329 2975]
 [7573 5341 7545]]

I have already gone through this question and read the docs but it goes in vain.

Can anyone please explain the math behind it in detail, right from 1D matrix to 3/4D Matrix. I am aware about the output shape. I want to know that, How can I calculate it manually? Please show some light on axes too.

A detailed example with different matrix dimensions and different axes value would be much appreciated.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP