Skip to content

Commit

Permalink
Refactor Gram matrix normalization for memory efficiency
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Friedman committed May 6, 2022
1 parent f86a567 commit f88e917
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion preimage/kernels/generic_string.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def _normalize(self, gram_matrix, X1, x1_lengths, X2, x2_lengths, is_symmetric,
else:
x1_norm = c_norm_fun(X1, x1_lengths)
x2_norm = c_norm_fun(X2, x2_lengths)
gram_matrix = ((gram_matrix / np.sqrt(x2_norm)).T / np.sqrt(x1_norm)).T
gram_matrix = gram_matrix / np.sqrt(x2_norm) / np.sqrt(x1_norm[:, np.newaxis])
return gram_matrix

def transform(self, x):
Expand Down

0 comments on commit f88e917

Please sign in to comment.