Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.ops.random_poisson

mindspore.ops.random_poisson(shape, rate, seed=None, dtype=mstype.float32)[source]

Generates random number Tensor with shape shape according to a Poisson distribution with mean rate.

P(i|μ)=exp(μ)μii!
Parameters
  • shape (Tensor) – The shape of random tensor to be sampled from each poisson distribution, 1-D Tensor whose dtype is mstype.int32 or mstype.int64.

  • rate (Tensor) – The μ parameter the distribution is constructed with. It represents the mean of the distribution and also the variance of the distribution. It should be a Tensor whose dtype is mstype.int64, mstype.int32, mstype.float64, mstype.float32 or mstype.float16.

  • seed (int, optional) – Seed is used as entropy source for the random number engines to generate pseudo-random numbers and must be non-negative. Default: None , which will be treated as 0.

  • dtype (mindspore.dtype) – The data type of output: mstype.int64, mstype.int32, mstype.float64, mstype.float32 or mstype.float16. Default: mstype.float32.

Returns

A Tensor whose shape is mindspore.concat([‘shape’, mindspore.shape(‘rate’)], axis=0) and data type is equal to argument dtype.

Raises
  • TypeError – If shape is not a Tensor.

  • TypeError – If datatype of shape is not mstype.int64 nor mstype.int32.

  • ValueError – If shape of shape is not 1-D.

  • TypeError – If rate is not a Tensor nor a scalar.

  • TypeError – If datatype of rate is not in [mstype.int64, mstype.int32, mstype.float64, mstype.float32 or mstype.float16].

  • TypeError – If seed is not a non-negtive int.

  • TypeError – If dtype is not in [mstype.int64, mstype.int32, mstype.float64, mstype.float32 nor mstype.float16].

  • ValueError – If any element of input shape tensor is not positive.

Supported Platforms:

GPU CPU

Examples

>>> import mindspore
>>> import numpy as np
>>> from mindspore import Tensor, ops
>>> # case 1: 1-D shape, 2-D rate, float64 output
>>> shape = Tensor(np.array([2, 2]), mindspore.int64)
>>> rate = Tensor(np.array([[5.0, 10.0], [5.0, 1.0]]), mindspore.float32)
>>> output = ops.random_poisson(shape, rate, seed=5, dtype=mindspore.float64)
>>> print(output.shape, output.dtype)
(2, 2, 2, 2) Float64
>>> # case 2: 1-D shape, scalar rate, int64 output
>>> shape = Tensor(np.array([2, 2]), mindspore.int64)
>>> rate = Tensor(5.0, mindspore.float64)
>>> output = ops.random_poisson(shape, rate, seed=5, dtype=mindspore.int64)
>>> print(output.shape, output.dtype)
(2, 2) Int64