Sets the seed for random operations. ```python exec="true" source="above" session="tensor" result="python" Tensor.manual_seed(42) print(Tensor.rand(5).numpy()) print(Tensor.rand(5).numpy()) ``` ```python exec="true" source="above" session="tensor" result="python" Te
(seed=0)
| 533 | _device_rng_counters: dict[str, Tensor] = {} |
| 534 | @staticmethod |
| 535 | def manual_seed(seed=0) -> None: |
| 536 | """ |
| 537 | Sets the seed for random operations. |
| 538 | |
| 539 | ```python exec="true" source="above" session="tensor" result="python" |
| 540 | Tensor.manual_seed(42) |
| 541 | print(Tensor.rand(5).numpy()) |
| 542 | print(Tensor.rand(5).numpy()) |
| 543 | ``` |
| 544 | ```python exec="true" source="above" session="tensor" result="python" |
| 545 | Tensor.manual_seed(42) # reset to the same seed |
| 546 | print(Tensor.rand(5).numpy()) |
| 547 | print(Tensor.rand(5).numpy()) |
| 548 | ``` |
| 549 | """ |
| 550 | Tensor._seed, Tensor._device_seeds, Tensor._device_rng_counters = seed, {}, {} |
| 551 | |
| 552 | @staticmethod |
| 553 | def _next_counter(device:str, num:int) -> tuple[Tensor, Tensor]: |
no outgoing calls