nystrom-ncut 0.0.7__tar.gz → 0.0.8__tar.gz
Sign up to get free protection for your applications and to get access to all the features.
- {nystrom_ncut-0.0.7/src/nystrom_ncut.egg-info → nystrom_ncut-0.0.8}/PKG-INFO +1 -1
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/pyproject.toml +1 -1
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/src/nystrom_ncut/ncut_pytorch.py +1 -1
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/src/nystrom_ncut/propagation_utils.py +10 -28
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/src/nystrom_ncut/visualize_utils.py +2 -7
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8/src/nystrom_ncut.egg-info}/PKG-INFO +1 -1
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/LICENSE +0 -0
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/MANIFEST.in +0 -0
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/README.md +0 -0
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/requirements.txt +0 -0
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/setup.cfg +0 -0
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/src/nystrom_ncut/__init__.py +0 -0
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/src/nystrom_ncut/common.py +0 -0
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/src/nystrom_ncut/nystrom.py +0 -0
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/src/nystrom_ncut.egg-info/SOURCES.txt +0 -0
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/src/nystrom_ncut.egg-info/dependency_links.txt +0 -0
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/src/nystrom_ncut.egg-info/top_level.txt +0 -0
- {nystrom_ncut-0.0.7 → nystrom_ncut-0.0.8}/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.8
|
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/
|
@@ -98,7 +98,11 @@ def distance_from_features(
|
|
98
98
|
D = torch.cdist(features, features_B, p=2)
|
99
99
|
elif distance == "rbf":
|
100
100
|
D = torch.cdist(features, features_B, p=2) ** 2
|
101
|
-
|
101
|
+
|
102
|
+
# Outlier-robust scale invariance using quantiles to estimate standard deviation
|
103
|
+
stds = torch.quantile(features, q=torch.tensor((0.158655, 0.841345), device=features.device), dim=0)
|
104
|
+
stds = (stds[1] - stds[0]) / 2
|
105
|
+
D = D / (2 * torch.linalg.norm(stds) ** 2)
|
102
106
|
else:
|
103
107
|
raise ValueError("distance should be 'cosine' or 'euclidean', 'rbf'")
|
104
108
|
return D
|
@@ -178,39 +182,17 @@ def extrapolate_knn(
|
|
178
182
|
V_list = []
|
179
183
|
for _v in torch.chunk(extrapolation_features, n_chunks, dim=0):
|
180
184
|
_v = _v.to(device) # [_m x d]
|
185
|
+
|
181
186
|
_A = affinity_from_features(anchor_features, _v, affinity_focal_gamma, distance).mT # [_m x n]
|
182
187
|
if knn is not None:
|
183
188
|
_A, indices = _A.topk(k=knn, dim=-1, largest=True) # [_m x k], [_m x k]
|
184
189
|
_anchor_output = anchor_output[indices] # [_m x k x d]
|
185
190
|
else:
|
186
191
|
_anchor_output = anchor_output[None] # [1 x n x d]
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
# elif distance == 'euclidean':
|
192
|
-
# _A = - torch.cdist(_v, subgraph_features, p=2)
|
193
|
-
# elif distance == 'rbf':
|
194
|
-
# _A = - torch.cdist(_v, subgraph_features, p=2) ** 2
|
195
|
-
# else:
|
196
|
-
# raise ValueError("distance should be 'cosine' or 'euclidean', 'rbf'")
|
197
|
-
#
|
198
|
-
# # keep topk KNN for each row
|
199
|
-
# topk_sim, topk_idx = _A.topk(knn, dim=-1, largest=True)
|
200
|
-
# row_id = torch.arange(topk_idx.shape[0], device=_A.device)[:, None].expand(
|
201
|
-
# -1, topk_idx.shape[1]
|
202
|
-
# )
|
203
|
-
# _A = torch.sparse_coo_tensor(
|
204
|
-
# torch.stack([row_id, topk_idx], dim=-1).reshape(-1, 2).T,
|
205
|
-
# topk_sim.reshape(-1),
|
206
|
-
# size=(_A.shape[0], _A.shape[1]),
|
207
|
-
# device=_A.device,
|
208
|
-
# )
|
209
|
-
# _A = _A.to_dense().to(dtype=subgraph_output.dtype)
|
210
|
-
# _D = _A.sum(-1)
|
211
|
-
# _A /= _D[:, None]
|
212
|
-
|
213
|
-
_V = (_A[:, None, :] @ _anchor_output).squeeze(1)
|
192
|
+
|
193
|
+
_A = Fn.normalize(_A, p=1, dim=-1) # [_m x k]
|
194
|
+
_V = (_A[:, None, :] @ _anchor_output).squeeze(1) # [_m x d]
|
195
|
+
|
214
196
|
if move_output_to_cpu:
|
215
197
|
_V = _V.cpu()
|
216
198
|
V_list.append(_V)
|
@@ -38,14 +38,9 @@ def _rgb_with_dimensionality_reduction(
|
|
38
38
|
) -> Tuple[torch.Tensor, torch.Tensor]:
|
39
39
|
|
40
40
|
if pre_smooth:
|
41
|
-
_subgraph_indices = run_subgraph_sampling(
|
42
|
-
features,
|
43
|
-
num_sample,
|
44
|
-
sample_method="farthest",
|
45
|
-
)
|
46
41
|
features = extrapolate_knn(
|
47
|
-
features
|
48
|
-
features
|
42
|
+
features,
|
43
|
+
features,
|
49
44
|
features,
|
50
45
|
distance="cosine",
|
51
46
|
)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: nystrom_ncut
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.8
|
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
|