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
Copy file name to clipboardExpand all lines: torchhd/functional.py
+21-30Lines changed: 21 additions & 30 deletions
Original file line number
Diff line number
Diff line change
@@ -37,7 +37,6 @@ def identity_hv(
37
37
num_embeddings: int,
38
38
embedding_dim: int,
39
39
*,
40
-
out=None,
41
40
dtype=None,
42
41
device=None,
43
42
requires_grad=False,
@@ -49,7 +48,6 @@ def identity_hv(
49
48
Args:
50
49
num_embeddings (int): the number of hypervectors to generate.
51
50
embedding_dim (int): the dimensionality of the hypervectors.
52
-
out (Tensor, optional): the output tensor.
53
51
dtype (``torch.dtype``, optional): the desired data type of returned tensor. Default: if ``None``, uses a global default (see ``torch.set_default_tensor_type()``).
54
52
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.
55
53
requires_grad (bool, optional): If autograd should record operations on the returned tensor. Default: ``False``.
@@ -67,7 +65,6 @@ def identity_hv(
67
65
returntorch.ones(
68
66
num_embeddings,
69
67
embedding_dim,
70
-
out=out,
71
68
dtype=dtype,
72
69
device=device,
73
70
requires_grad=requires_grad,
@@ -78,8 +75,8 @@ def random_hv(
78
75
num_embeddings: int,
79
76
embedding_dim: int,
80
77
*,
78
+
sparsity=0.5,
81
79
generator=None,
82
-
out=None,
83
80
dtype=None,
84
81
device=None,
85
82
requires_grad=False,
@@ -91,38 +88,38 @@ def random_hv(
91
88
Args:
92
89
num_embeddings (int): the number of hypervectors to generate.
93
90
embedding_dim (int): the dimensionality of the hypervectors.
91
+
sparsity (float, optional): the expected fraction of elements to be +1. Default: ``0.5``.
94
92
generator (``torch.Generator``, optional): a pseudorandom number generator for sampling.
95
-
out (Tensor, optional): the output tensor.
96
93
dtype (``torch.dtype``, optional): the desired data type of returned tensor. Default: if ``None``, uses a global default (see ``torch.set_default_tensor_type()``).
97
94
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.
98
95
requires_grad (bool, optional): If autograd should record operations on the returned tensor. Default: ``False``.
embedding_dim (int): the dimensionality of the hypervectors.
147
143
randomness (float, optional): r-value to interpolate between level at ``0.0`` and random-hypervectors at ``1.0``. Default: ``0.0``.
148
144
generator (``torch.Generator``, optional): a pseudorandom number generator for sampling.
149
-
out (Tensor, optional): the output tensor.
150
145
dtype (``torch.dtype``, optional): the desired data type of returned tensor. Default: if ``None``, uses a global default (see ``torch.set_default_tensor_type()``).
151
146
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.
152
147
requires_grad (bool, optional): If autograd should record operations on the returned tensor. Default: ``False``.
@@ -164,7 +159,6 @@ def level_hv(
164
159
hv=torch.zeros(
165
160
num_embeddings,
166
161
embedding_dim,
167
-
out=out,
168
162
dtype=dtype,
169
163
device=device,
170
164
)
@@ -219,7 +213,6 @@ def circular_hv(
219
213
*,
220
214
randomness=0.0,
221
215
generator=None,
222
-
out=None,
223
216
dtype=None,
224
217
device=None,
225
218
requires_grad=False,
@@ -234,7 +227,6 @@ def circular_hv(
234
227
embedding_dim (int): the dimensionality of the hypervectors.
235
228
randomness (float, optional): r-value to interpolate between circular at ``0.0`` and random-hypervectors at ``1.0``. Default: ``0.0``.
236
229
generator (``torch.Generator``, optional): a pseudorandom number generator for sampling.
237
-
out (Tensor, optional): the output tensor.
238
230
dtype (``torch.dtype``, optional): the desired data type of returned tensor. Default: if ``None``, uses a global default (see ``torch.set_default_tensor_type()``).
239
231
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.
240
232
requires_grad (bool, optional): If autograd should record operations on the returned tensor. Default: ``False``.
0 commit comments