Given tensors x with shape [a, n] and y with shape [b,n] and function f(p,q) operating on tensors of shape [1,n] (or [n]) and returning a scalar value, how can I compute f pair-wise over the batch dimensions of x and y so that my resulting tensor is [a,b,1] (or [a,b])?
I know that this works for operations like multiplication and addition, as described here:Evaluate all pair combinations of rows of two tensors in tensorflow via implicit broadcasting.
How can this be extended to arbitrary functions?
The application is I would like to compute the pair-wise KL divergence for two tensors to match them, so basically a brute force NN computation.