oneflow.normal

oneflow.normal(mean, std, size, *, out=None, placement=None, sbp=None, generator=None, dtype=None, device=None, requires_grad=False)Tensor

Returns a tensor of random numbers drawn from separate normal distributions whose mean and standard deviation are given.

Parameters
  • mean (float) – the mean for all distributions

  • std (float) – the standard deviation for all distributions

  • size (int...) – a sequence of integers defining the shape of the output tensor.

Keyword Arguments
  • out (Tensor, optional) – the output tensor.

  • placement (flow.placement, optional) – The desired device of returned global tensor. If None, will construct local tensor.

  • sbp (flow.sbp, optional) – The desired sbp of returned global tensor. It must be equal with the numbers of placement.

  • generator (oneflow.Generator, optional) – a pseudorandom number generator for sampling

  • dtype (oneflow.dtype, optional) – the desired data type of returned tensor. Default: oneflow.float32.

  • device – the desired device of returned tensor. Default: cpu.

  • requires_grad (bool, optional) – If autograd should record operations on the returned tensor. Default: False.

Example:

>>> import oneflow as flow
>>> generator = flow.Generator()
>>> generator.manual_seed(0)
>>> y = flow.normal(0, 1, 5, generator=generator)
>>> y
tensor([2.2122, 1.1631, 0.7740, 0.4838, 1.0434], dtype=oneflow.float32)