You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
"The circular hypervectors don't currently work with the HRR model. We are not sure why, if you have any insight that could help please share it at: https://github.com/hyperdimensional-computing/torchhd/issues/108."
491
+
)
492
+
487
493
# convert from normalized "randomness" variable r to
488
494
# number of levels between orthogonal pairs or "span"
"""Creates a set of hypervectors representing empty sets.
29
+
30
+
When bundled with a random-hypervector :math:`x`, the result is :math:`x`.
31
+
The empty vector of the HRR model is simply a set of 0 values.
32
+
33
+
Args:
34
+
num_vectors (int): the number of hypervectors to generate.
35
+
dimensions (int): the dimensionality of the hypervectors.
36
+
dtype (``torch.dtype``, optional): the desired data type of returned tensor. Default: if ``None`` is ``torch.get_default_dtype()``.
37
+
device (``torch.device``, optional): the desired device of returned tensor. Default: if ``None``, uses the current device for the default tensor type (see torch.set_default_tensor_type()). ``device`` will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.
38
+
requires_grad (bool, optional): If autograd should record operations on the returned tensor. Default: ``False``.
When bound with a random-hypervector :math:`x`, the result is :math:`x`.
83
+
84
+
Args:
85
+
num_vectors (int): the number of hypervectors to generate.
86
+
dimensions (int): the dimensionality of the hypervectors.
87
+
dtype (``torch.dtype``, optional): the desired data type of returned tensor. Default: if ``None`` is ``torch.get_default_dtype()``.
88
+
device (``torch.device``, optional): the desired device of returned tensor. Default: if ``None``, uses the current device for the default tensor type (see torch.set_default_tensor_type()). ``device`` will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.
89
+
requires_grad (bool, optional): If autograd should record operations on the returned tensor. Default: ``False``.
raiseValueError(f"{name} vectors must be one of dtype {options}.")
59
111
60
-
result=torch.ones(
112
+
result=torch.zeros(
61
113
num_vectors,
62
114
dimensions,
63
115
dtype=dtype,
64
116
device=device,
65
117
)
66
-
result=torch.real(ifft(result))
118
+
result[:, 0] =1
67
119
result.requires_grad=requires_grad
68
120
returnresult.as_subclass(cls)
69
121
@@ -78,6 +130,29 @@ def random_hv(
78
130
device=None,
79
131
requires_grad=False,
80
132
) ->"HRR":
133
+
"""Creates a set of random independent hypervectors.
134
+
135
+
The resulting hypervectors are sampled at random from a normal with mean 0 and standard deviation 1/dimensions.
136
+
137
+
Args:
138
+
num_vectors (int): the number of hypervectors to generate.
139
+
dimensions (int): the dimensionality of the hypervectors.
140
+
generator (``torch.Generator``, optional): a pseudorandom number generator for sampling.
141
+
dtype (``torch.dtype``, optional): the desired data type of returned tensor. Default: if ``None`` is ``torch.get_default_dtype()``.
142
+
device (``torch.device``, optional): the desired device of returned tensor. Default: if ``None``, uses the current device for the default tensor type (see torch.set_default_tensor_type()). ``device`` will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types.
143
+
requires_grad (bool, optional): If autograd should record operations on the returned tensor. Default: ``False``.
0 commit comments