MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / normal_

Function normal_

imperative/python/megengine/module/init.py:53–62  ·  view source on GitHub ↗

r"""Fills the given ``tensor`` with random value sampled from normal distribution :math:`\mathcal{N}(\text{mean}, \text{std}^2)`. Args: tensor: tensor to be initialized. mean: mean of the normal distribution. std: standard deviation of the normal distribution.

(tensor: Tensor, mean: float = 0.0, std: float = 1.0)

Source from the content-addressed store, hash-verified

51
52
53def normal_(tensor: Tensor, mean: float = 0.0, std: float = 1.0) -> None:
54 r"""Fills the given ``tensor`` with random value sampled from normal distribution
55 :math:`\mathcal{N}(\text{mean}, \text{std}^2)`.
56
57 Args:
58 tensor: tensor to be initialized.
59 mean: mean of the normal distribution.
60 std: standard deviation of the normal distribution.
61 """
62 tensor._reset(normal(size=tensor.shape, mean=mean, std=std).astype(tensor.dtype))
63
64
65def calculate_gain(

Callers 2

xavier_normal_Function · 0.85
msra_normal_Function · 0.85

Calls 2

_resetMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected