MCPcopy
hub / github.com/tinygrad/tinygrad / glorot_uniform

Method glorot_uniform

tinygrad/tensor.py:739–752  ·  view source on GitHub ↗

You can pass in `dtype` and `device` keyword arguments to control the data type and device of the tensor. Additionally, all other keyword arguments are passed to the constructor of the tensor. ```pyth

(*shape, **kwargs)

Source from the content-addressed store, hash-verified

737
738 @staticmethod
739 def glorot_uniform(*shape, **kwargs) -> Tensor:
740 """
741 <https://www.tensorflow.org/api_docs/python/tf/keras/initializers/GlorotUniform>
742
743 You can pass in `dtype` and `device` keyword arguments to control the data type and device of the tensor.
744 Additionally, all other keyword arguments are passed to the constructor of the tensor.
745
746 ```python exec="true" source="above" session="tensor" result="python"
747 Tensor.manual_seed(42)
748 print(Tensor.glorot_uniform(2, 3).numpy())
749 ```
750 """
751 bound = (6 / (argfix(*shape)[0]+prod(argfix(*shape)[1:]))) ** 0.5
752 return Tensor.uniform(*shape, low=-bound, high=bound, **kwargs)
753
754 @staticmethod
755 def kaiming_uniform(*shape, a:float = 0.01, **kwargs) -> Tensor:

Callers 3

__init__Method · 0.80
__init__Method · 0.80
__init__Method · 0.80

Calls 3

argfixFunction · 0.90
prodFunction · 0.90
uniformMethod · 0.80

Tested by

no test coverage detected