mygrad.random.randn#

mygrad.random.randn(*shape: int, constant: Optional[bool] = None) Tensor[source]#

Return a sample (or samples) from the “standard normal” distribution.

Parameters
shape: shape: d0, d1, … dnint, optional

The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.

constantOptional[bool]

If True, this tensor is treated as a constant, and thus does not facilitate back propagation (i.e. constant.grad will always return None).

Defaults to False for float-type data. Defaults to True for integer-type data.

Integer-type tensors must be constant.

Returns
mygrad.Tensor

A shape-shaped Tensor of floating-point samples from the standard normal distribution, or a single such float if no parameters were supplied.

Examples

>>> from mygrad.random import randn
>>> randn(3, 3, 2)
Tensor([[[-0.45664135,  0.05060159],
         [ 1.36883177, -0.46084292],
         [-0.76647664,  0.81667174]],
[[ 0.08336453, -1.35104408],

[ 0.73187355, 1.33405382], [ 0.28411209, -0.18047323]],

[[-0.2239412 , -0.09170368],

[-0.39175898, 0.81260396], [-1.28788909, -1.52525778]]])