Say v1
and v2
has the same shape. Is it possible in tensorflow to concat v1
and the transposed version of v2
using the broadcast semantic?
For example,
v1 = tf.constant([[1,1,1,1],[3,3,3,3],[5,5,5,5]])
v2 = tf.constant([[2,2,2,2],[4,4,4,4]])
I want to produce something like
[
[[[1,1,1,1], [2,2,2,2]],
[[1,1,1,1], [4,4,4,4]]],
[[[3,3,3,3], [2,2,2,2]],
[[3,3,3,3], [4,4,4,4]]],
[[[5,5,5,5], [2,2,2,2]],
[[5,5,5,5], [4,4,4,4]]]]
that is, with v1
as [3, 4]
and v2
as [2,4]
, I want to do
tf.concat([v1, tf.transpose(v2)], axis=0)
and produce a [3,2,2,4]
matrix.
Is there any trick for doing that?