Skip to content

Fix incorrect variable usage in EMG example #136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/emg_hand_gestures.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def __init__(self, out_features, timestamps, channels):
def forward(self, input: torch.Tensor) -> torch.Tensor:
signal = self.signals(input)
samples = torchhd.bind(signal, self.channels.weight.unsqueeze(0))
samples = torchhd.bind(signal, self.timestamps.weight.unsqueeze(1))
samples = torchhd.bind(samples, self.timestamps.weight.unsqueeze(1))

samples = torchhd.multiset(samples)
sample_hv = torchhd.ngrams(samples, n=N_GRAM_SIZE)
Expand Down
2 changes: 1 addition & 1 deletion torchhd/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ def ngrams(input: VSATensor, n: int = 3) -> VSATensor:
\bigoplus_{i=0}^{m - n} \bigotimes_{j = 0}^{n - 1} \Pi^{n - j - 1}(V_{i + j})

.. note::
For :math:`n=1` use :func:`~torchhd.functional.multiset` instead and for :math:`n=m` use :func:`~torchhd.functional.bind_sequence` instead.
For :math:`n=1` use :func:`~torchhd.multiset` instead and for :math:`n=m` use :func:`~torchhd.bind_sequence` instead.

Args:
input (VSATensor): The value hypervectors.
Expand Down
4 changes: 2 additions & 2 deletions torchhd/tests/test_encodings.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def test_value(self, vsa, dtype):
def test_dtype(self, dtype):
hv = torch.zeros(23, 1000, dtype=dtype).as_subclass(MAPTensor)

if dtype in {torch.float16, torch.bfloat16}:
if dtype in {torch.float16}:
# torch.product is not implemented on CPU for these dtypes
with pytest.raises(RuntimeError):
functional.multibind(hv)
Expand Down Expand Up @@ -287,7 +287,7 @@ def test_value(self):
def test_dtype(self, dtype):
hv = torch.zeros(23, 1000, dtype=dtype).as_subclass(MAPTensor)

if dtype in {torch.float16, torch.bfloat16}:
if dtype in {torch.float16}:
# torch.product is not implemented on CPU for these dtypes
with pytest.raises(RuntimeError):
functional.multibind(hv)
Expand Down