nystrom-ncut 0.0.10__tar.gz → 0.0.11__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {nystrom_ncut-0.0.10/src/nystrom_ncut.egg-info → nystrom_ncut-0.0.11}/PKG-INFO +1 -1
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/pyproject.toml +1 -1
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/src/nystrom_ncut/nystrom/distance_realization.py +14 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/src/nystrom_ncut/visualize_utils.py +9 -16
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11/src/nystrom_ncut.egg-info}/PKG-INFO +1 -1
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/LICENSE +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/MANIFEST.in +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/README.md +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/requirements.txt +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/setup.cfg +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/src/__init__.py +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/src/nystrom_ncut/__init__.py +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/src/nystrom_ncut/common.py +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/src/nystrom_ncut/nystrom/__init__.py +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/src/nystrom_ncut/nystrom/normalized_cut.py +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/src/nystrom_ncut/nystrom/nystrom.py +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/src/nystrom_ncut/propagation_utils.py +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/src/nystrom_ncut.egg-info/SOURCES.txt +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/src/nystrom_ncut.egg-info/dependency_links.txt +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/src/nystrom_ncut.egg-info/top_level.txt +0 -0
- {nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/tests/test.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: nystrom_ncut
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.11
|
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/
|
{nystrom_ncut-0.0.10 → nystrom_ncut-0.0.11}/src/nystrom_ncut/nystrom/distance_realization.py
RENAMED
@@ -1,3 +1,5 @@
|
|
1
|
+
from typing import Tuple
|
2
|
+
|
1
3
|
import torch
|
2
4
|
|
3
5
|
from .nystrom import (
|
@@ -125,3 +127,15 @@ class DistanceRealization(OnlineNystromSubsampleFit):
|
|
125
127
|
chunk_size=chunk_size,
|
126
128
|
)
|
127
129
|
self.distance: DistanceOptions = distance
|
130
|
+
|
131
|
+
def fit_transform(
|
132
|
+
self,
|
133
|
+
features: torch.Tensor,
|
134
|
+
precomputed_sampled_indices: torch.Tensor = None,
|
135
|
+
) -> torch.Tensor:
|
136
|
+
V, L = OnlineNystromSubsampleFit.fit_transform(self, features, precomputed_sampled_indices)
|
137
|
+
return V * (L ** 0.5)
|
138
|
+
|
139
|
+
def transform(self, features: torch.Tensor = None) -> torch.Tensor:
|
140
|
+
V, L = OnlineNystromSubsampleFit.transform(features)
|
141
|
+
return V * (L ** 0.5)
|
@@ -11,6 +11,9 @@ from .common import (
|
|
11
11
|
quantile_min_max,
|
12
12
|
quantile_normalize,
|
13
13
|
)
|
14
|
+
from .nystrom import (
|
15
|
+
DistanceRealization,
|
16
|
+
)
|
14
17
|
from .propagation_utils import (
|
15
18
|
run_subgraph_sampling,
|
16
19
|
extrapolate_knn,
|
@@ -192,18 +195,9 @@ def rgb_from_cosine_tsne_3d(
|
|
192
195
|
)
|
193
196
|
perplexity = num_sample // 2
|
194
197
|
|
195
|
-
|
196
198
|
def cosine_to_rbf(X: torch.Tensor) -> torch.Tensor: # [B... x N x 3]
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
G = (D[..., :1, 1:] ** 2 + D[..., 1:, :1] ** 2 - D[..., 1:, 1:] ** 2) / 2 # [B... x (N - 1) x (N - 1)]
|
201
|
-
L, V = torch.linalg.eigh(G) # [B... x (N - 1)], [B... x (N - 1) x (N - 1)]
|
202
|
-
sqrtG = V[..., -3:] * (L[..., None, -3:] ** 0.5) # [B... x (N - 1) x 3]
|
203
|
-
|
204
|
-
Y = torch.cat((torch.zeros_like(sqrtG[..., :1, :]), sqrtG), dim=-2) # [B... x N x 3]
|
205
|
-
Y = Y - torch.mean(Y, dim=-2, keepdim=True)
|
206
|
-
return Y
|
199
|
+
dr = DistanceRealization(n_components=3, num_sample=20000, distance="cosine", eig_solver="lobpcg")
|
200
|
+
return dr.fit_transform(X)
|
207
201
|
|
208
202
|
def rgb_from_cosine(X_3d: torch.Tensor, q: float) -> torch.Tensor:
|
209
203
|
return rgb_from_3d_rgb_cube(cosine_to_rbf(X_3d), q=q)
|
@@ -379,7 +373,6 @@ def rotate_rgb_cube(rgb, position=1):
|
|
379
373
|
|
380
374
|
def rgb_from_3d_rgb_cube(X_3d, q=0.95):
|
381
375
|
"""convert 3D t-SNE to RGB color space
|
382
|
-
|
383
376
|
Args:
|
384
377
|
X_3d (torch.Tensor): 3D t-SNE embedding, shape (n_samples, 3)
|
385
378
|
q (float): quantile, default 0.95
|
@@ -389,10 +382,10 @@ def rgb_from_3d_rgb_cube(X_3d, q=0.95):
|
|
389
382
|
"""
|
390
383
|
assert X_3d.shape[1] == 3, "input should be (n_samples, 3)"
|
391
384
|
assert len(X_3d.shape) == 2, "input should be (n_samples, 3)"
|
392
|
-
rgb = [
|
393
|
-
|
394
|
-
|
395
|
-
|
385
|
+
rgb = torch.stack([
|
386
|
+
quantile_normalize(x, q=q)
|
387
|
+
for x in torch.unbind(X_3d, dim=1)
|
388
|
+
], dim=-1)
|
396
389
|
return rgb
|
397
390
|
|
398
391
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: nystrom_ncut
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.11
|
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/
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|