MCPcopy
hub / github.com/tinygrad/tinygrad / kaiming_normal

Method kaiming_normal

tinygrad/tensor.py:771–784  ·  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. ```python

(*shape, a:float = 0.01, **kwargs)

Source from the content-addressed store, hash-verified

769
770 @staticmethod
771 def kaiming_normal(*shape, a:float = 0.01, **kwargs) -> Tensor:
772 """
773 <https://pytorch.org/docs/stable/_modules/torch/nn/init.html#kaiming_normal_>
774
775 You can pass in `dtype` and `device` keyword arguments to control the data type and device of the tensor.
776 Additionally, all other keyword arguments are passed to the constructor of the tensor.
777
778 ```python exec="true" source="above" session="tensor" result="python"
779 Tensor.manual_seed(42)
780 print(Tensor.kaiming_normal(2, 3).numpy())
781 ```
782 """
783 std = (2 / (1 + a ** 2) / prod(argfix(*shape)[1:])) ** 0.5
784 return Tensor.normal(*shape, mean=0.0, std=std, **kwargs)
785
786 @staticmethod
787 def randperm(n:int, device=None, dtype=dtypes.int32, **kwargs) -> Tensor:

Callers

nothing calls this directly

Calls 3

prodFunction · 0.90
argfixFunction · 0.90
normalMethod · 0.80

Tested by

no test coverage detected