Skip to content

Commit f352ea4

Browse files
committed
fix TVN
1 parent 1f8ee6f commit f352ea4

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

experiments/tvn.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@ def fit(self, dmso_features: torch.Tensor):
2626
"""
2727
Fits the PCA model on the given DMSO feature set, storing the mean and components.
2828
"""
29+
n_samples, n_features = dmso_features.shape
30+
n_components = min(n_samples, n_features)
31+
pca = PCA(n_components=n_components, whiten=self.whiten)
2932
# Convert to numpy for sklearn PCA
30-
pca = PCA(n_components=dmso_features.shape[1], whiten=self.whiten)
3133
pca.fit(dmso_features.cpu().numpy())
3234
self.mean_ = torch.tensor(pca.mean_, dtype=torch.float32)
3335
self.components_ = torch.tensor(pca.components_, dtype=torch.float32)

0 commit comments

Comments
 (0)