MCPcopy
hub / github.com/GPflow/GPflow / broadcasting_elementwise

Function broadcasting_elementwise

gpflow/utilities/ops.py:87–96  ·  view source on GitHub ↗

Apply binary operation `op` to every pair in tensors `a` and `b`. :param op: binary operator on tensors, e.g. tf.add, tf.substract

(
    op: Callable[[tf.Tensor, tf.Tensor], tf.Tensor], a: tf.Tensor, b: tf.Tensor
)

Source from the content-addressed store, hash-verified

85 "return: [a_shape..., b_shape...]",
86)
87def broadcasting_elementwise(
88 op: Callable[[tf.Tensor, tf.Tensor], tf.Tensor], a: tf.Tensor, b: tf.Tensor
89) -> tf.Tensor:
90 """
91 Apply binary operation `op` to every pair in tensors `a` and `b`.
92
93 :param op: binary operator on tensors, e.g. tf.add, tf.substract
94 """
95 flatres = op(tf.reshape(a, [-1, 1]), tf.reshape(b, [1, -1]))
96 return tf.reshape(flatres, tf.concat([tf.shape(a), tf.shape(b)], 0))
97
98
99@check_shapes(

Callers 1

square_distanceFunction · 0.85

Calls 1

shapeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…