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

Method normal

imperative/python/megengine/random/rng.py:345–374  ·  view source on GitHub ↗

r"""Random variable with Gaussian distribution :math:`N(\mu, \sigma)`. Args: mean(float): the mean or expectation of the distribution. Default: 0. std(float): the standard deviation of the distribution (variance = :math:`\sigma ^ 2`). Default: 1.

(
        self, mean: float = 0, std: float = 1, size: Optional[Iterable[int]] = None
    )

Source from the content-addressed store, hash-verified

343 )
344
345 def normal(
346 self, mean: float = 0, std: float = 1, size: Optional[Iterable[int]] = None
347 ):
348 r"""Random variable with Gaussian distribution :math:`N(\mu, \sigma)`.
349
350 Args:
351 mean(float): the mean or expectation of the distribution. Default: 0.
352 std(float): the standard deviation of the distribution (variance = :math:`\sigma ^ 2`).
353 Default: 1.
354 size(Optional[Iterable[int]]): the size of output tensor. Default: None.
355
356 Returns:
357 Return type: tensor. The random variable with Gaussian distribution.
358
359 Examples:
360 >>> import megengine.random as rand
361 >>> x = rand.normal(mean=0, std=1, size=(2, 2))
362 >>> x.numpy() # doctest: +SKIP
363 array([[ 1.5534291 , -0.28356555],
364 [ 2.2230418 , -0.92425716]], dtype=float32)
365 """
366 _seed = self._seed() if callable(self._seed) else self._seed
367 return _normal(
368 mean=mean,
369 std=std,
370 size=size,
371 seed=_seed,
372 device=self._device,
373 handle=self._handle,
374 )
375
376 def gamma(
377 self,

Callers 15

test_NormalRNGFunction · 0.95
benchmark_op.pyFile · 0.80
_apply_imageMethod · 0.80
_apply_imageMethod · 0.80
test_ViTmode_trace_trainFunction · 0.80
fnFunction · 0.80
fn3Function · 0.80
fwdFunction · 0.80
test_funcFunction · 0.80
test_rnn_cellFunction · 0.80
test_lstm_cellFunction · 0.80
test_rnnFunction · 0.80

Calls 1

_normalFunction · 0.85

Tested by 15

test_NormalRNGFunction · 0.76
test_ViTmode_trace_trainFunction · 0.64
fnFunction · 0.64
fn3Function · 0.64
fwdFunction · 0.64
test_funcFunction · 0.64
test_rnn_cellFunction · 0.64
test_lstm_cellFunction · 0.64
test_rnnFunction · 0.64
test_lstmFunction · 0.64
test_syncbnFunction · 0.64
test_batchnormFunction · 0.64