Let a
and b
be tensors defined as:
a = tf.constant([[1, 4],
[2, 5],
[3, 6]], tf.float32)
b = tf.constant([[10, 40],
[20, 50],
[30, 60]], tf.float32)
I am looking for a way to multiply each column of a
by all columns of b
, producing a result as below:
[[10, 40, 40, 160],
[40, 100, 100, 250],
[90, 180, 180, 360]]
I need an operation that can be performed over a tensor with an arbitrary number of columns (> 2).
I already developed a solution that can be used within a loop. You can checkout it here.
Thank you for you attention.
Do I miss something? Why not just
edit: add
foo.shape.as_list()
You can try this:
For bigger matrices, however, you have to adjust the indexing.