nystrom-ncut 0.0.3__py3-none-any.whl → 0.0.4__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.py +15 -10
- {nystrom_ncut-0.0.3.dist-info → nystrom_ncut-0.0.4.dist-info}/METADATA +1 -1
- {nystrom_ncut-0.0.3.dist-info → nystrom_ncut-0.0.4.dist-info}/RECORD +6 -6
- {nystrom_ncut-0.0.3.dist-info → nystrom_ncut-0.0.4.dist-info}/LICENSE +0 -0
- {nystrom_ncut-0.0.3.dist-info → nystrom_ncut-0.0.4.dist-info}/WHEEL +0 -0
- {nystrom_ncut-0.0.3.dist-info → nystrom_ncut-0.0.4.dist-info}/top_level.txt +0 -0
nystrom_ncut/nystrom.py
CHANGED
@@ -52,6 +52,18 @@ class OnlineNystrom:
|
|
52
52
|
self.transform_matrix: torch.Tensor = None # [n x n_components]
|
53
53
|
self.LS: torch.Tensor = None # [n]
|
54
54
|
|
55
|
+
def _update_to_kernel(self) -> Tuple[torch.Tensor, torch.Tensor]:
|
56
|
+
self.A = self.S = self.kernel.transform()
|
57
|
+
U, L = solve_eig(
|
58
|
+
self.A,
|
59
|
+
num_eig=self.inverse_approximation_dim,
|
60
|
+
eig_solver=self.eig_solver,
|
61
|
+
) # [n x (? + 1)], [? + 1]
|
62
|
+
self.Ahinv_UL = U * (L ** -0.5) # [n x (? + 1)]
|
63
|
+
self.Ahinv_VT = U.mT # [(? + 1) x n]
|
64
|
+
self.Ahinv = self.Ahinv_UL @ self.Ahinv_VT # [n x n]
|
65
|
+
return U, L
|
66
|
+
|
55
67
|
def fit(self, features: torch.Tensor):
|
56
68
|
OnlineNystrom.fit_transform(self, features)
|
57
69
|
return self
|
@@ -60,17 +72,8 @@ class OnlineNystrom:
|
|
60
72
|
self.anchor_features = features
|
61
73
|
|
62
74
|
self.kernel.fit(self.anchor_features)
|
63
|
-
self.A = self.S = self.kernel.transform() # [n x n]
|
64
|
-
|
65
75
|
self.inverse_approximation_dim = max(self.n_components, features.shape[-1]) + 1
|
66
|
-
U, L =
|
67
|
-
self.A,
|
68
|
-
num_eig=self.inverse_approximation_dim,
|
69
|
-
eig_solver=self.eig_solver,
|
70
|
-
) # [n x (? + 1)], [? + 1]
|
71
|
-
self.Ahinv_UL = U * (L ** -0.5) # [n x (? + 1)]
|
72
|
-
self.Ahinv_VT = U.mT # [(? + 1) x n]
|
73
|
-
self.Ahinv = self.Ahinv_UL @ self.Ahinv_VT # [n x n]
|
76
|
+
U, L = self._update_to_kernel() # [n x (? + 1)], [? + 1]
|
74
77
|
|
75
78
|
self.transform_matrix = (U / L)[:, :self.n_components] # [n x n_components]
|
76
79
|
self.LS = L[:self.n_components] # [n_components]
|
@@ -83,6 +86,7 @@ class OnlineNystrom:
|
|
83
86
|
chunks = torch.chunk(features, n_chunks, dim=0)
|
84
87
|
for chunk in chunks:
|
85
88
|
self.kernel.update(chunk)
|
89
|
+
self._update_to_kernel()
|
86
90
|
|
87
91
|
compressed_BBT = torch.zeros((self.inverse_approximation_dim, self.inverse_approximation_dim)) # [(? + 1) x (? + 1))]
|
88
92
|
for i, chunk in enumerate(chunks):
|
@@ -101,6 +105,7 @@ class OnlineNystrom:
|
|
101
105
|
else:
|
102
106
|
""" Unchunked version """
|
103
107
|
B = self.kernel.update(features).mT # [n x m]
|
108
|
+
self._update_to_kernel()
|
104
109
|
compressed_B = self.Ahinv_VT @ B # [indirect_pca_dim x m]
|
105
110
|
|
106
111
|
self.S = self.S + self.Ahinv_UL @ (compressed_B @ compressed_B.mT) @ self.Ahinv_UL.mT # [n x n]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: nystrom_ncut
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.4
|
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/
|
@@ -1,11 +1,11 @@
|
|
1
1
|
nystrom_ncut/__init__.py,sha256=Cww-_OsyQHLKpgw_Wh28_tUOvIMMr7Ey8w-tH7v99xQ,452
|
2
2
|
nystrom_ncut/common.py,sha256=qdR_JwknT9H1Cv5LopwdwZfORFx-O8MLiRI6ZF1Qohc,558
|
3
3
|
nystrom_ncut/ncut_pytorch.py,sha256=8LfznDwhq-WL_vQxbFBFLSzymg9SEDti_zzf9QQLnrA,11651
|
4
|
-
nystrom_ncut/nystrom.py,sha256=
|
4
|
+
nystrom_ncut/nystrom.py,sha256=HbwON9pLW3gEZvOmbDJwkQNHolOo1EBvwBPeh2p2uJE,8833
|
5
5
|
nystrom_ncut/propagation_utils.py,sha256=pigecB0rAmlbCoMNb8zhCyyNwh3QzkxXEnaBsDRE_ns,12136
|
6
6
|
nystrom_ncut/visualize_utils.py,sha256=oNaDz_Xn12g3knEZZTb-QWVN-wTrnCNE5gn9cu8Xl_U,18569
|
7
|
-
nystrom_ncut-0.0.
|
8
|
-
nystrom_ncut-0.0.
|
9
|
-
nystrom_ncut-0.0.
|
10
|
-
nystrom_ncut-0.0.
|
11
|
-
nystrom_ncut-0.0.
|
7
|
+
nystrom_ncut-0.0.4.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
|
8
|
+
nystrom_ncut-0.0.4.dist-info/METADATA,sha256=dog8rG5_vF31_SJS90ruUeJwnrs3bM635m7KSPLht78,6058
|
9
|
+
nystrom_ncut-0.0.4.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
|
10
|
+
nystrom_ncut-0.0.4.dist-info/top_level.txt,sha256=j7g_j0S048EvguFFnGgD5Ewd3r2H6klsxd5A4dd-wHw,13
|
11
|
+
nystrom_ncut-0.0.4.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|