Creates a tensor with the given shape, filled with random values from a normal distribution with the given `mean` and standard deviation `std`. Requires `std >= 0`. You can pass in `dtype` and `device` keyword arguments to control the data type and device of the tensor. Additionall
(*shape, mean=0.0, std=1.0, **kwargs)
| 686 | |
| 687 | @staticmethod |
| 688 | def normal(*shape, mean=0.0, std=1.0, **kwargs) -> Tensor: |
| 689 | """ |
| 690 | Creates a tensor with the given shape, filled with random values from a normal distribution with the given `mean` and standard deviation `std`. |
| 691 | Requires `std >= 0`. |
| 692 | |
| 693 | You can pass in `dtype` and `device` keyword arguments to control the data type and device of the tensor. |
| 694 | Additionally, all other keyword arguments are passed to the constructor of the tensor. |
| 695 | |
| 696 | ```python exec="true" source="above" session="tensor" result="python" |
| 697 | Tensor.manual_seed(42) |
| 698 | print(Tensor.normal(2, 3, mean=10, std=2).numpy()) |
| 699 | ``` |
| 700 | """ |
| 701 | if std < 0: raise ValueError(f"Tensor.normal requires std >= 0, got {std=}") |
| 702 | return std * Tensor.randn(*shape, **kwargs) + mean |
| 703 | |
| 704 | @staticmethod |
| 705 | def uniform(*shape, low=0.0, high=1.0, dtype:DTypeLike|None=None, **kwargs) -> Tensor: |