nystrom-ncut 0.2.0__py3-none-any.whl → 0.2.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nystrom_ncut/nystrom/nystrom_utils.py +1 -0
- nystrom_ncut/transformer/axis_align.py +8 -4
- nystrom_ncut/transformer/transformer_mixin.py +2 -0
- {nystrom_ncut-0.2.0.dist-info → nystrom_ncut-0.2.2.dist-info}/METADATA +1 -1
- {nystrom_ncut-0.2.0.dist-info → nystrom_ncut-0.2.2.dist-info}/RECORD +8 -8
- {nystrom_ncut-0.2.0.dist-info → nystrom_ncut-0.2.2.dist-info}/LICENSE +0 -0
- {nystrom_ncut-0.2.0.dist-info → nystrom_ncut-0.2.2.dist-info}/WHEEL +0 -0
- {nystrom_ncut-0.2.0.dist-info → nystrom_ncut-0.2.2.dist-info}/top_level.txt +0 -0
@@ -93,6 +93,7 @@ class OnlineNystrom(TorchTransformerMixin):
|
|
93
93
|
|
94
94
|
self.transform_matrix = (U / L)[:, :self.n_components] # [n x n_components]
|
95
95
|
self.eigenvalues_ = L[:self.n_components] # [n_components]
|
96
|
+
self.is_fitted = True
|
96
97
|
return U[:, :self.n_components] # [n x n_components]
|
97
98
|
|
98
99
|
def update(self, features: torch.Tensor) -> torch.Tensor:
|
@@ -1,4 +1,3 @@
|
|
1
|
-
import random
|
2
1
|
from typing import Literal
|
3
2
|
|
4
3
|
import torch
|
@@ -14,7 +13,7 @@ class AxisAlign(TorchTransformerMixin):
|
|
14
13
|
Args:
|
15
14
|
max_iter (int, optional): Maximum number of iterations.
|
16
15
|
"""
|
17
|
-
SortOptions = Literal["count", "norm"]
|
16
|
+
SortOptions = Literal["count", "norm", "marginal_norm"]
|
18
17
|
|
19
18
|
def __init__(
|
20
19
|
self,
|
@@ -33,7 +32,7 @@ class AxisAlign(TorchTransformerMixin):
|
|
33
32
|
|
34
33
|
# Initialize R matrix with the first column from a random row of EigenVectors
|
35
34
|
self.R = torch.empty((d, d), device=X.device)
|
36
|
-
self.R[0] = normalized_X[
|
35
|
+
self.R[0] = normalized_X[torch.randint(0, n, (), device=X.device)]
|
37
36
|
|
38
37
|
# Loop to populate R with k orthogonal directions
|
39
38
|
c = torch.zeros((n,), device=X.device)
|
@@ -62,11 +61,16 @@ class AxisAlign(TorchTransformerMixin):
|
|
62
61
|
if self.sort_method == "count":
|
63
62
|
sort_metric = torch.bincount(idx, minlength=d)
|
64
63
|
elif self.sort_method == "norm":
|
65
|
-
|
64
|
+
rotated_X = X @ self.R.mT
|
65
|
+
sort_metric = torch.linalg.norm(rotated_X, dim=0)
|
66
|
+
elif self.sort_method == "marginal_norm":
|
67
|
+
rotated_X = X @ self.R.mT
|
68
|
+
sort_metric = torch.zeros((d,), device=X.device).index_add_(0, idx, rotated_X[range(n), idx] ** 2)
|
66
69
|
else:
|
67
70
|
raise ValueError(f"Invalid sort method {self.sort_method}.")
|
68
71
|
|
69
72
|
self.R = self.R[torch.argsort(sort_metric, dim=0, descending=True)]
|
73
|
+
self.is_fitted = True
|
70
74
|
return self
|
71
75
|
|
72
76
|
def transform(self, X: torch.Tensor, normalize: bool = True, hard: bool = False) -> torch.Tensor:
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: nystrom_ncut
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.2
|
4
4
|
Summary: Normalized Cut and Nyström Approximation
|
5
5
|
Author-email: Huzheng Yang <huze.yann@gmail.com>, Wentinn Liao <wentinn.liao@gmail.com>
|
6
6
|
Project-URL: Documentation, https://github.com/JophiArcana/Nystrom-NCUT/
|
@@ -7,12 +7,12 @@ nystrom_ncut/visualize_utils.py,sha256=d3VXjzJPZPPyUMg_b8hKLQoBaRWvutu6u7l36S2gm
|
|
7
7
|
nystrom_ncut/nystrom/__init__.py,sha256=lAoO00i4FG5xqGKDO_OYcSvO4qPK64x_X_hDNBvuLUc,105
|
8
8
|
nystrom_ncut/nystrom/distance_realization.py,sha256=InajllGtRVnLVlZoipZNbHFTGHaTs3zxizKe3kI2Los,5815
|
9
9
|
nystrom_ncut/nystrom/normalized_cut.py,sha256=2ocwc4U3A6GGFs0cuL0DO1yNvt59SJ3uDtj00U0foPM,5906
|
10
|
-
nystrom_ncut/nystrom/nystrom_utils.py,sha256=
|
10
|
+
nystrom_ncut/nystrom/nystrom_utils.py,sha256=MMRMq7N_JYM2whSHIhCoPA-SQ28wb9hC8u2CZNmRRN8,12836
|
11
11
|
nystrom_ncut/transformer/__init__.py,sha256=jjXjcNp3LrxeF6mqG9VY5k3asrqaY6bXzJz6wTpH78Q,105
|
12
|
-
nystrom_ncut/transformer/axis_align.py,sha256=
|
13
|
-
nystrom_ncut/transformer/transformer_mixin.py,sha256=
|
14
|
-
nystrom_ncut-0.2.
|
15
|
-
nystrom_ncut-0.2.
|
16
|
-
nystrom_ncut-0.2.
|
17
|
-
nystrom_ncut-0.2.
|
18
|
-
nystrom_ncut-0.2.
|
12
|
+
nystrom_ncut/transformer/axis_align.py,sha256=8PYtSTChHDTrh5SYdhl1ALsUUPJHd9ojQRM1e6KTbHc,3579
|
13
|
+
nystrom_ncut/transformer/transformer_mixin.py,sha256=kVjODpIHB6noC7yGY-QPf67Ep58o53wrEMKSNjhhChI,1714
|
14
|
+
nystrom_ncut-0.2.2.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
|
15
|
+
nystrom_ncut-0.2.2.dist-info/METADATA,sha256=RGX2HMT2uF9bUB_4qecpX87bY6N1gg6-QKXvhJVnzIo,6058
|
16
|
+
nystrom_ncut-0.2.2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
17
|
+
nystrom_ncut-0.2.2.dist-info/top_level.txt,sha256=gM8IWWHYysIRTCvCTcdS4RShOyl9pxpylgSwPUZR2XM,22
|
18
|
+
nystrom_ncut-0.2.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|