mindspore.numpy.rand
- mindspore.numpy.rand(*shape, dtype=mstype.float32)[source]
Returns a new Tensor with given shape and dtype, filled with random numbers from the uniform distribution on the interval \([0, 1)\).
- Parameters
- Returns
Tensor, with the designated shape and dtype, filled with random numbers from the uniform distribution on the interval \([0, 1)\).
- Raises
TypeError – If input arguments have types not specified above.
ValueError – If dtype is not float type.
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> 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]]