Skip to content

Commit

Permalink
reduce memory_footprint for transform
Browse files Browse the repository at this point in the history
  • Loading branch information
Intron7 committed Jul 12, 2024
1 parent 1e7de60 commit 1c0582b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions python/cuml/decomposition/pca.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -632,8 +632,9 @@ class PCA(UniversalBase,
self.components_ *= cp.sqrt(self.n_samples_ - 1)
self.components_ /= self.singular_values_.reshape((-1, 1))

X = X - self.mean_
X_transformed = X.dot(self.components_.T)
precomputed_mean_impact = self.mean_ @ self.components_.T
mean_impact = cp.ones((X.shape[0], 1)) @ precomputed_mean_impact.reshape(1, -1)
X_transformed = X.dot(self.components_.T) -mean_impact

if self.whiten:
self.components_ *= self.singular_values_.reshape((-1, 1))
Expand Down

0 comments on commit 1c0582b

Please sign in to comment.