doc: manual_seed (#4987)

there was a docstring just not linked to the doc page. also updated the example to show re-seed instead of a internal variable
This commit is contained in:
chenyu 2024-06-15 19:57:26 -04:00 committed by GitHub
parent ce1ed374c9
commit 20b50d8d64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 1 deletions

View File

@ -12,6 +12,7 @@
## Creation (random)
::: tinygrad.Tensor.manual_seed
::: tinygrad.Tensor.rand
::: tinygrad.Tensor.randn
::: tinygrad.Tensor.randint

View File

@ -372,7 +372,13 @@ class Tensor:
```python exec="true" source="above" session="tensor" result="python"
Tensor.manual_seed(42)
print(Tensor._seed)
print(Tensor.rand(5).numpy())
print(Tensor.rand(5).numpy())
```
```python exec="true" source="above" session="tensor" result="python"
Tensor.manual_seed(42) # reset to the same seed
print(Tensor.rand(5).numpy())
print(Tensor.rand(5).numpy())
```
"""
Tensor._seed, Tensor._rng_counter = seed, Tensor([0], dtype=dtypes.uint32, requires_grad=False)