标题中的问题-如何将这些形状的两个张量相乘以产生该形状的张量?
c
[Batch_Size, A, B] x [Batch_Size, B] = [Batch_Size, A]
要求张量的等级相同。
答案 0 :(得分:0)
import tensorflow as tf
tensor1 = tf.zeros([10, 64, 64])
tensor2 = tf.zeros([10, 64])
# dot = tf.matmul(tensor1, tensor2) # NOT THIS
dot = tf.einsum('ijk,ik->ij', tensor1, tensor2)
with tf.Session() as sess:
print(sess.run(dot).shape)