【发布时间】:2019-12-20 15:48:32
【问题描述】:
我正在尝试对 tf.tensordot 轴参数的行为进行逆向工程,但遇到了困难。
给定以下代码:
a = tf.constant([[1., 2.], [3., 4.], [4., 5.]])
b = tf.constant([1., 2.])
c = tf.constant([[1., 2.], [2., 3.], [3., 4.]])
print(f'Shape of c: {c.shape}')
ct = tf.transpose(c)
print(f'Shape of ct: {ct.shape}')
print('.................')
d = tf.tensordot(a, ct, axes=1)
print(f'Shape of d: {d.shape}')
print(d)
print('.................')
e = tf.tensordot(a, ct, axes=0)
print(f'Shape of e: {e.shape}')
print(e)
print('.................')
f = tf.tensordot(a, ct, axes=2)
print(f'Shape of f: {f.shape}')
print(e)
我了解“d”是如何产生的,但我不明白“e”和“f”是如何产生的。 TensorFlow Documentation 不足以让我理解。
【问题讨论】:
标签: tensorflow tensor axes dot-product multiple-axes