Deep-Learning-for-Causal-Inference icon indicating copy to clipboard operation
Deep-Learning-for-Causal-Inference copied to clipboard

Is the implementation of the function `pdist2sq` corrected?

Open Ywandung-Lyou opened this issue 3 years ago • 1 comments

In the implementation, na and nb is not used.

def pdist2sq(A, B):
    #helper for PEHEnn
    #calculates squared euclidean distance between rows of two matrices  
    #https://gist.github.com/mbsariyildiz/34cdc26afb630e8cae079048eef91865
    # squared norms of each row in A and B
    na = tf.reduce_sum(tf.square(A), 1)
    nb = tf.reduce_sum(tf.square(B), 1)    
    # na as a row and nb as a column vectors
    na = tf.reshape(na, [-1, 1])
    nb = tf.reshape(nb, [1, -1])
    # return pairwise euclidean difference matrix
    D=tf.reduce_sum((tf.expand_dims(A, 1)-tf.expand_dims(B, 0))**2,2) 
    return D

Ywandung-Lyou avatar Nov 03 '21 09:11 Ywandung-Lyou

Hi Ywandung,

I really appreciate the feedback! I think I've fixed this issue, let me know!

-B

kochbj avatar Oct 17 '22 16:10 kochbj