nystrom-ncut 0.3.4__tar.gz → 0.3.5__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 (28) hide show
  1. {nystrom_ncut-0.3.4/src/nystrom_ncut.egg-info → nystrom_ncut-0.3.5}/PKG-INFO +1 -1
  2. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/pyproject.toml +1 -1
  3. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/kernel/kernel_ncut.py +6 -1
  4. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5/src/nystrom_ncut.egg-info}/PKG-INFO +1 -1
  5. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/LICENSE +0 -0
  6. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/MANIFEST.in +0 -0
  7. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/README.md +0 -0
  8. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/requirements.txt +0 -0
  9. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/setup.cfg +0 -0
  10. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/__init__.py +0 -0
  11. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/__init__.py +0 -0
  12. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/common.py +0 -0
  13. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/distance_utils.py +0 -0
  14. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/global_settings.py +0 -0
  15. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/kernel/__init__.py +0 -0
  16. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/nystrom/__init__.py +0 -0
  17. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/nystrom/distance_realization.py +0 -0
  18. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/nystrom/normalized_cut.py +0 -0
  19. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/nystrom/nystrom_utils.py +0 -0
  20. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/sampling_utils.py +0 -0
  21. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/transformer/__init__.py +0 -0
  22. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/transformer/axis_align.py +0 -0
  23. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/transformer/transformer_mixin.py +0 -0
  24. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut/visualize_utils.py +0 -0
  25. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut.egg-info/SOURCES.txt +0 -0
  26. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut.egg-info/dependency_links.txt +0 -0
  27. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/src/nystrom_ncut.egg-info/top_level.txt +0 -0
  28. {nystrom_ncut-0.3.4 → nystrom_ncut-0.3.5}/tests/test.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nystrom_ncut
3
- Version: 0.3.4
3
+ Version: 0.3.5
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.3.4"
7
+ version = "0.3.5"
8
8
  authors = [
9
9
  { name = "Huzheng Yang", email = "huze.yann@gmail.com" },
10
10
  { name = "Wentinn Liao", email = "wentinn.liao@gmail.com" },
@@ -28,10 +28,12 @@ class KernelNCutBaseTransformer(OnlineTorchTransformerMixin):
28
28
  self.affinity_focal_gamma = affinity_focal_gamma
29
29
 
30
30
  # Anchor matrices
31
+ self.anchor_count: int = None # n
31
32
  self.W: torch.Tensor = None # [... x d x kernel_dim]
32
33
  self.kernelized_anchor: torch.Tensor = None # [... x n x (2 * kernel_dim)]
33
34
 
34
35
  # Updated matrices
36
+ self.total_count: int = None # m
35
37
  self.r: torch.Tensor = None # [... x (2 * kernel_dim)]
36
38
  self.transform_matrix: torch.Tensor = None # [... x (2 * kernel_dim) x n_components]
37
39
  self.eigenvalues_: torch.Tensor = None # [... x n_components]
@@ -42,10 +44,12 @@ class KernelNCutBaseTransformer(OnlineTorchTransformerMixin):
42
44
  _, S, V = torch.svd_lowrank(torch.nan_to_num(
43
45
  normalized_kernelized_anchor, nan=0.0,
44
46
  ), q=self.n_components) # [... x n_components], [... x (2 * kernel_dim) x n_components]
45
- self.transform_matrix = V * torch.nan_to_num(1 / S, posinf=0.0, neginf=0.0)[..., None, :] # [... x (2 * kernel_dim) x n_components]
47
+ S = S * (self.total_count / self.anchor_count) ** 0.5
48
+ self.transform_matrix = V * torch.nan_to_num(1 / S, posinf=0.0, neginf=0.0)[..., None, :] # [... x (2 * kernel_dim) x n_components]
46
49
  self.eigenvalues_ = S ** 2
47
50
 
48
51
  def fit(self, features: torch.Tensor) -> "KernelNCutBaseTransformer":
52
+ self.anchor_count = self.total_count = features.shape[-2]
49
53
  d = features.shape[-1]
50
54
  scale = get_normalization_factor(features) * (self.affinity_focal_gamma ** 0.5) # [...]
51
55
  self.W = torch.randn((*features.shape[:-2], d, self.kernel_dim)) / scale[..., None, None] # [... x d x kernel_dim]
@@ -60,6 +64,7 @@ class KernelNCutBaseTransformer(OnlineTorchTransformerMixin):
60
64
  return self
61
65
 
62
66
  def update(self, features: torch.Tensor) -> torch.Tensor:
67
+ self.total_count += features.shape[-2]
63
68
  W_features = features @ self.W # [... x m x kernel_dim]
64
69
  kernelized_features = torch.cat((
65
70
  torch.cos(W_features),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: nystrom_ncut
3
- Version: 0.3.4
3
+ Version: 0.3.5
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