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

Function uniform_

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

r"""Fills the given ``tensor`` with random value sampled from uniform distribution :math:`\mathcal{U}(\text{a}, \text{b})`. Args: tensor: tensor to be initialized. a: lower bound of the sampling interval. b: upper bound of the sampling interval.

(tensor: Tensor, a: float = 0.0, b: float = 1.0)

Source from the content-addressed store, hash-verified

39
40
41def uniform_(tensor: Tensor, a: float = 0.0, b: float = 1.0) -> None:
42 r"""Fills the given ``tensor`` with random value sampled from uniform distribution
43 :math:`\mathcal{U}(\text{a}, \text{b})`.
44
45 Args:
46 tensor: tensor to be initialized.
47 a: lower bound of the sampling interval.
48 b: upper bound of the sampling interval.
49 """
50 tensor._reset(uniform(size=tensor.shape, low=a, high=b).astype(tensor.dtype))
51
52
53def normal_(tensor: Tensor, mean: float = 0.0, std: float = 1.0) -> None:

Callers 2

xavier_uniform_Function · 0.85
msra_uniform_Function · 0.85

Calls 2

_resetMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected