mindspore.numpy.rand
- mindspore.numpy.rand(*shape, dtype=mstype.float32)[源代码]
Returns a new Tensor with given shape and dtype, filled with random numbers from the uniform distribution on the interval \([0, 1)\).
- 参数
- 返回
Tensor, with the designated shape and dtype, filled with random numbers from the uniform distribution on the interval \([0, 1)\).
- 异常
TypeError – If input arguments have types not specified above.
ValueError – If dtype is not float type.
- Supported Platforms:
Ascend
GPU
CPU
样例
>>> import mindspore.numpy as np >>> from mindspore import set_seed >>> set_seed(1) >>> print(np.rand((2,3))) [[4.1702199e-01 9.9718481e-01 7.2032452e-01] [9.3255734e-01 1.1438108e-04 1.2812445e-01]]