Creates a tensor with the same shape and sharding as `self`, filled with random values from a uniform distribution over the interval `[0, 1)`. You can pass in `dtype` and `device` keyword arguments to control the data type and device of the tensor. Additionally, all other keyword argum
(self, **kwargs)
| 617 | return Tensor.full(self.shape, fill_value, dtype=dtype or self.dtype, device=device) |
| 618 | |
| 619 | def rand_like(self, **kwargs) -> Tensor: |
| 620 | """ |
| 621 | Creates a tensor with the same shape and sharding as `self`, filled with random values from a uniform distribution over the interval `[0, 1)`. |
| 622 | |
| 623 | You can pass in `dtype` and `device` keyword arguments to control the data type and device of the tensor. |
| 624 | Additionally, all other keyword arguments are passed to the constructor of the tensor. |
| 625 | |
| 626 | ```python exec="true" source="above" session="tensor" result="python" |
| 627 | t = Tensor.ones(2, 3) |
| 628 | print(Tensor.rand_like(t).numpy()) |
| 629 | ``` |
| 630 | """ |
| 631 | if isinstance(self.device, tuple): return self._multi_like(Tensor.rand, **kwargs) |
| 632 | return Tensor.rand(*self.shape, device=kwargs.pop("device", self.device), dtype=kwargs.pop("dtype", self.dtype), **kwargs) |
| 633 | |
| 634 | # ***** random functions ***** |
| 635 |