Is there a function in Tensorflow can do the following math?

Viewed 50

I have two tensors, x and y, of shape [B, D]. I want to do something like the following code

B, D = x.shape
x = tf.expand_dims(x, 1)  # [B, 1, D]
y = tf.expand_dims(y, -1) # [B, D, 1]
z = x * y                 # [B, D, D]
z = tf.reshape(z, (B, D**2))

Is there a function in Tensorflow that already does this?

0 Answers
Related