contextnet/utils/utils.py
def compute_distances_no_loops(Y, X):
    """
    Compute the distance between each test point in X and each training point
    in self.X_train using no explicit loops.

    Input / Output: Same as compute_distances_two_loops
    """
    dists = np.zeros((Y.shape[0], X.shape[0]))

    dists -= 2 * X @ Y.T
    dists += (np.sum(Y**2, axis=1))
    dists = dists.T + np.sum(X**2, axis=1)
    dists = dists.T
    return np.sqrt(dists)

    Compute the distance between each test point in X and each training point
    in self.X_train using no explicit loops.

    Input / Output: Same as compute_distances_two_loops
    
Compute the distance between each test point in X and each training point
in self.X_train using no explicit loops.

Input / Output: Same as compute_distances_two_loops
Compute the distance between each test point in X and each training point in self . X_train using no explicit loops . Input / Output : Same as compute_distances_two_loops
def compute_distances_no_loops(Y, X):
    dists = np.zeros((Y.shape[0], X.shape[0]))
    dists -= 2 * X @ Y.T
    dists += (np.sum(Y**2, axis=1))
    dists = dists.T + np.sum(X**2, axis=1)
    dists = dists.T
    return np.sqrt(dists)
def compute_distances_no_loops ( Y , X ) : dists = np . zeros ( ( Y . shape [ 0 ] , X . shape [ 0 ] ) ) dists -= 2 * X @ Y . T dists += ( np . sum ( Y ** 2 , axis = 1 ) ) dists = dists . T + np . sum ( X ** 2 , axis = 1 ) dists = dists . T return np . sqrt ( dists )
Compute the distance between each test point in X and each training point
in self.X_train using no explicit loops.
Compute the distance between each test point in X and each training point in self . X_train using no explicit loops .
"""
    Compute the distance between each test point in X and each training point
    in self.X_train using no explicit loops.

    Input / Output: Same as compute_distances_two_loops
    """
Y
X