mindspore.ops.RandomPoisson
- class mindspore.ops.RandomPoisson(seed=0, seed2=0, dtype=mstype.int64)[source]
Produces random non-negative values i, distributed according to discrete probability function:
\[\text{P}(i|μ) = \frac{\exp(-μ)μ^{i}}{i!}\]- Parameters
seed (int, optional) – Random number seed. If either seed or seed2 are set to be non-zero, the seed is set by the given seed. Otherwise, it is seeded by a random seed. Default: 0.
seed2 (int, optional) – A second seed to avoid seed collision. Default: 0.
dtype (mindspore.dtype, optional) – The type of output. Default: mstype.int64.
- Inputs:
shape (Tensor) - The shape of random tensor to be generated, 1-D Tensor, whose dtype must be in [int32, int64].
rate (Tensor) - μ parameter the distribution was constructed with. The parameter defines mean number of occurrences of the event. Its type must be in [float16, float32, float64, int32, int64].
- Outputs:
Tensor. Its shape is \((*shape, *rate.shape)\). Its type is specified by dtype.
- Raises
TypeError – If shape is not a Tensor or its dtype is not int32 or int64.
TypeError – If dtype is not int32 or int64.
ValueError – If shape is not a 1-D tensor.
ValueError – If shape elements are negative.
- Supported Platforms:
GPU
CPU
Examples
>>> shape = Tensor(np.array([2, 3]), mstype.int32) >>> rate = Tensor(np.array([2, 2]), mstype.int32) >>> seed = 0 >>> seed2 = 0 >>> random_poisson = ops.RandomPoisson(seed=seed, seed2=seed2) >>> output = random_poisson(shape,rate) >>> print(output.shape) (2, 3, 2)