Skip to content

Commit 535f56b

Browse files
authored
Randsel probablity is flipped with documentation (#162)
1 parent 527249d commit 535f56b

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

torchhd/functional.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ def randsel(
11041104
other = ensure_vsa_tensor(other)
11051105

11061106
select = torch.empty_like(input, dtype=torch.bool)
1107-
select.bernoulli_(1 - p, generator=generator)
1107+
select.bernoulli_(p, generator=generator)
11081108
return input.where(select, other)
11091109

11101110

torchhd/tests/test_operations.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def test_value(self, vsa, dtype):
272272
else:
273273
a, b = functional.random(2, 1024, vsa, dtype=dtype, generator=generator)
274274
res = functional.randsel(a, b, p=0, generator=generator)
275-
assert torch.all(a == res)
275+
assert torch.all(b == res)
276276

277277
if vsa == "BSBC":
278278
a, b = functional.random(
@@ -281,7 +281,7 @@ def test_value(self, vsa, dtype):
281281
else:
282282
a, b = functional.random(2, 1024, vsa, dtype=dtype, generator=generator)
283283
res = functional.randsel(a, b, p=1, generator=generator)
284-
assert torch.all(b == res)
284+
assert torch.all(a == res)
285285

286286
if vsa == "BSBC":
287287
a, b = functional.random(

0 commit comments

Comments
 (0)