Skip to content

Commit

Permalink
doc: manual_seed (tinygrad#4987)
Browse files Browse the repository at this point in the history
there was a docstring just not linked to the doc page. also updated the example to show re-seed instead of a internal variable
  • Loading branch information
chenyuxyz authored Jun 15, 2024
1 parent ce1ed37 commit 20b50d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/tensor/creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

## Creation (random)

::: tinygrad.Tensor.manual_seed
::: tinygrad.Tensor.rand
::: tinygrad.Tensor.randn
::: tinygrad.Tensor.randint
Expand Down
8 changes: 7 additions & 1 deletion tinygrad/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,13 @@ def manual_seed(seed=0):
```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)
Expand Down

0 comments on commit 20b50d8

Please sign in to comment.