nystrom-ncut 0.2.0__py3-none-any.whl → 0.2.1__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.
@@ -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[random.randint(0, n - 1)]
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,7 +61,11 @@ 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
- sort_metric = torch.linalg.norm(X @ self.R.mT, dim=0)
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
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nystrom_ncut
3
- Version: 0.2.0
3
+ Version: 0.2.1
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/
@@ -9,10 +9,10 @@ nystrom_ncut/nystrom/distance_realization.py,sha256=InajllGtRVnLVlZoipZNbHFTGHaT
9
9
  nystrom_ncut/nystrom/normalized_cut.py,sha256=2ocwc4U3A6GGFs0cuL0DO1yNvt59SJ3uDtj00U0foPM,5906
10
10
  nystrom_ncut/nystrom/nystrom_utils.py,sha256=5w-2GAMb7b6ArZdPEnAnKPFFrsbHSfC-S78cvrR6O20,12806
11
11
  nystrom_ncut/transformer/__init__.py,sha256=jjXjcNp3LrxeF6mqG9VY5k3asrqaY6bXzJz6wTpH78Q,105
12
- nystrom_ncut/transformer/axis_align.py,sha256=UHPbZVs3XFDvxAQHJC2La8W534k3nJ776DEfQeJVKxg,3297
12
+ nystrom_ncut/transformer/axis_align.py,sha256=6LTR-syJ-f4pcbnMexFmFNn1QADDhH5gka6979YBRrI,3549
13
13
  nystrom_ncut/transformer/transformer_mixin.py,sha256=YAjrDWTL5Hjnk9J2OsoxvtwT2N0u8IdgMSx0rRFmZzE,1653
14
- nystrom_ncut-0.2.0.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
15
- nystrom_ncut-0.2.0.dist-info/METADATA,sha256=rKIYYECCawfOcjVLx6OZJAo5ngi2uKriNLbgKVEs_IY,6058
16
- nystrom_ncut-0.2.0.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
17
- nystrom_ncut-0.2.0.dist-info/top_level.txt,sha256=gM8IWWHYysIRTCvCTcdS4RShOyl9pxpylgSwPUZR2XM,22
18
- nystrom_ncut-0.2.0.dist-info/RECORD,,
14
+ nystrom_ncut-0.2.1.dist-info/LICENSE,sha256=2bm9uFabQZ3Ykb_SaSU_uUbAj2-htc6WJQmS_65qD00,1073
15
+ nystrom_ncut-0.2.1.dist-info/METADATA,sha256=l5t4vEFtPANsQY8PK0YHDJ1tw6dZUulU5daxX9T8QC0,6058
16
+ nystrom_ncut-0.2.1.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
17
+ nystrom_ncut-0.2.1.dist-info/top_level.txt,sha256=gM8IWWHYysIRTCvCTcdS4RShOyl9pxpylgSwPUZR2XM,22
18
+ nystrom_ncut-0.2.1.dist-info/RECORD,,