File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -65,13 +65,15 @@ def compute_pairwise_affinities(data_x: np.ndarray, sigma: float = 1.0) -> np.nd
6565 n_samples = data_x .shape [0 ]
6666 sum_x = np .sum (np .square (data_x ), axis = 1 )
6767 d = np .add (np .add (- 2 * np .dot (data_x , data_x .T ), sum_x ).T , sum_x )
68- p = np .exp (- d / (2 * sigma ** 2 ))
68+ p = np .exp (- d / (2 * sigma ** 2 ))
6969 np .fill_diagonal (p , 0 )
7070 p /= np .sum (p )
7171 return (p + p .T ) / (2 * n_samples )
7272
7373
74- def compute_low_dim_affinities (embedding_y : np .ndarray ) -> tuple [np .ndarray , np .ndarray ]:
74+ def compute_low_dim_affinities (
75+ embedding_y : np .ndarray ,
76+ ) -> tuple [np .ndarray , np .ndarray ]:
7577 """
7678 Computes low-dimensional similarities (Q matrix) using Student-t distribution.
7779
@@ -87,7 +89,9 @@ def compute_low_dim_affinities(embedding_y: np.ndarray) -> tuple[np.ndarray, np.
8789 (2, 2)
8890 """
8991 sum_y = np .sum (np .square (embedding_y ), axis = 1 )
90- num = 1 / (1 + np .add (np .add (- 2 * np .dot (embedding_y , embedding_y .T ), sum_y ).T , sum_y ))
92+ num = 1 / (
93+ 1 + np .add (np .add (- 2 * np .dot (embedding_y , embedding_y .T ), sum_y ).T , sum_y )
94+ )
9195 np .fill_diagonal (num , 0 )
9296 q = num / np .sum (num )
9397 return q , num
You can’t perform that action at this time.
0 commit comments