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/embeddings.py
+76-8Lines changed: 76 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@
11
11
"Level",
12
12
"Circular",
13
13
"Projection",
14
+
"Sinusoid",
14
15
]
15
16
16
17
@@ -230,7 +231,7 @@ class Projection(nn.Module):
230
231
r"""Embedding using a random projection matrix.
231
232
232
233
Implemented based on `A Theoretical Perspective on Hyperdimensional Computing <https://arxiv.org/abs/2010.07426>`_.
233
-
:math:`\Phi x` where :math:`\Phi \in \mathbb{R}^{d \times m}` is a matrix whose rows are uniformly sampled at random from the surface of an :math:`m`-dimensional unit sphere.
234
+
It computes :math:`x \Phi^{\mathsf{T}}` where :math:`\Phi \in \mathbb{R}^{d \times m}` is a matrix whose rows are uniformly sampled at random from the surface of an :math:`d`-dimensional unit sphere.
234
235
This encoding ensures that similarities in the input space are preserved in the hyperspace.
235
236
236
237
Args:
@@ -242,11 +243,16 @@ class Projection(nn.Module):
Implemented based on `Scalable Edge-Based Hyperdimensional Learning System with Brain-Like Neural Adaptation <https://dl.acm.org/doi/abs/10.1145/3458817.3480958>`_.
290
+
It computes :math:`\cos(x \Phi^{\mathsf{T}} + b) \odot \sin(x \Phi^{\mathsf{T}})` where :math:`\Phi \in \mathbb{R}^{d \times m}` is a matrix whose elements are sampled at random from a standard normal distribution and :math:`b \in \mathbb{R}^{d}` is a vectors whose elements are sampled uniformly at random between 0 and :math:`2\pi`.
291
+
292
+
Args:
293
+
in_features (int): the dimensionality of the input feature vector.
294
+
out_features (int): the dimensionality of the hypervectors.
295
+
requires_grad (bool, optional): If autograd should record operations on the returned tensor. Default: ``False``.
296
+
dtype (``torch.dtype``, optional): the desired data type of returned tensor. Default: if ``None``, uses a global default (see ``torch.set_default_tensor_type()``).
297
+
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.
0 commit comments