MCPcopy
hub / github.com/tinygrad/tinygrad / scaled_uniform

Method scaled_uniform

tinygrad/tensor.py:723–736  ·  view source on GitHub ↗

Creates a tensor with the given shape, filled with random values from a uniform distribution over the interval `[-prod(shape)**-0.5, prod(shape)**-0.5)`. You can pass in `dtype` and `device` keyword arguments to control the data type and device of the tensor. Additionally, all othe

(*shape, **kwargs)

Source from the content-addressed store, hash-verified

721
722 @staticmethod
723 def scaled_uniform(*shape, **kwargs) -> Tensor:
724 """
725 Creates a tensor with the given shape, filled with random values from a uniform distribution
726 over the interval `[-prod(shape)**-0.5, prod(shape)**-0.5)`.
727
728 You can pass in `dtype` and `device` keyword arguments to control the data type and device of the tensor.
729 Additionally, all other keyword arguments are passed to the constructor of the tensor.
730
731 ```python exec="true" source="above" session="tensor" result="python"
732 Tensor.manual_seed(42)
733 print(Tensor.scaled_uniform(2, 3).numpy())
734 ```
735 """
736 return Tensor.uniform(*shape, low=-1.0, high=1.0, **kwargs).mul(prod(argfix(*shape))**-0.5)
737
738 @staticmethod
739 def glorot_uniform(*shape, **kwargs) -> Tensor:

Callers 7

__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80

Calls 4

prodFunction · 0.90
argfixFunction · 0.90
mulMethod · 0.80
uniformMethod · 0.80

Tested by 3

__init__Method · 0.64
__init__Method · 0.64
__init__Method · 0.64