MCPcopy
hub / github.com/tinygrad/tinygrad / randn

Method randn

tinygrad/tensor.py:653–666  ·  view source on GitHub ↗

Creates a tensor with the given shape, filled with random values from a normal distribution with mean `0` and standard deviation `1`. If `dtype` is not specified, the default type is used. You can pass in the `device` keyword argument to control device of the tensor. Additionally,

(*shape, dtype:DTypeLike|None=None, **kwargs)

Source from the content-addressed store, hash-verified

651
652 @staticmethod
653 def randn(*shape, dtype:DTypeLike|None=None, **kwargs) -> Tensor:
654 """
655 Creates a tensor with the given shape, filled with random values from a normal distribution with mean `0` and standard deviation `1`.
656 If `dtype` is not specified, the default type is used.
657
658 You can pass in the `device` keyword argument to control device of the tensor.
659 Additionally, all other keyword arguments are passed to the constructor of the tensor.
660
661 ```python exec="true" source="above" session="tensor" result="python"
662 Tensor.manual_seed(42)
663 print(Tensor.randn(2, 3).numpy())
664 ```
665 """
666 return Tensor.empty(*shape, **kwargs).randn_like(dtype=dtype)
667
668 @staticmethod
669 def randint(*shape, low=0, high=10, dtype=dtypes.int32, **kwargs) -> Tensor:

Callers 15

normalMethod · 0.80
amx.pyFile · 0.80
eval_custom_matmulFunction · 0.80
gemm.pyFile · 0.80
halide_gemm.pyFile · 0.80
amd_matmul.pyFile · 0.80
hook_torch.pyFile · 0.80
fnMethod · 0.80
test_normalMethod · 0.80

Calls 2

randn_likeMethod · 0.80
emptyMethod · 0.45

Tested by 15

fnMethod · 0.64
test_normalMethod · 0.64
test_linalg_svdMethod · 0.64
_test_diagonalMethod · 0.64
test_matmul_backwardMethod · 0.64
test_permute_2Method · 0.64
test_diag_backwardMethod · 0.64
test_expand_backwardMethod · 0.64