nystrom-ncut 0.2.0__tar.gz → 0.2.1__tar.gz

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.
Files changed (25) hide show
  1. {nystrom_ncut-0.2.0/src/nystrom_ncut.egg-info → nystrom_ncut-0.2.1}/PKG-INFO +1 -1
  2. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/pyproject.toml +1 -1
  3. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut/transformer/axis_align.py +7 -4
  4. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1/src/nystrom_ncut.egg-info}/PKG-INFO +1 -1
  5. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/LICENSE +0 -0
  6. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/MANIFEST.in +0 -0
  7. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/README.md +0 -0
  8. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/requirements.txt +0 -0
  9. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/setup.cfg +0 -0
  10. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/__init__.py +0 -0
  11. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut/__init__.py +0 -0
  12. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut/common.py +0 -0
  13. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut/distance_utils.py +0 -0
  14. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut/nystrom/__init__.py +0 -0
  15. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut/nystrom/distance_realization.py +0 -0
  16. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut/nystrom/normalized_cut.py +0 -0
  17. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut/nystrom/nystrom_utils.py +0 -0
  18. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut/sampling_utils.py +0 -0
  19. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut/transformer/__init__.py +0 -0
  20. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut/transformer/transformer_mixin.py +0 -0
  21. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut/visualize_utils.py +0 -0
  22. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut.egg-info/SOURCES.txt +0 -0
  23. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut.egg-info/dependency_links.txt +0 -0
  24. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/src/nystrom_ncut.egg-info/top_level.txt +0 -0
  25. {nystrom_ncut-0.2.0 → nystrom_ncut-0.2.1}/tests/test.py +0 -0
@@ -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/
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "nystrom_ncut"
7
- version = "0.2.0"
7
+ version = "0.2.1"
8
8
  authors = [
9
9
  { name = "Huzheng Yang", email = "huze.yann@gmail.com" },
10
10
  { name = "Wentinn Liao", email = "wentinn.liao@gmail.com" },
@@ -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/
File without changes
File without changes
File without changes
File without changes
File without changes