Pair sum in tensor flow
3 answers
You can rely on broadcasting .
op1 = tf.expand_dims(A, axis=2)
op2 = tf.expand_dims(B, axis=1)
C = tf.add(op1, op2)
Beware that @MaxB's solution is not equivalent to this, as operator is []
equivalent to call strided_slice
, not expand_dims
.
0
source to share