mindspore.Tensor.uniform
- Tensor.uniform(from_=0., to=1., generator=None)[source]
- Generates random numbers that follows a uniform distribution within the half-open interval \([from\_, to)\). \[P(x)= \frac{1}{to - from\_}\]- Parameters
- from_ (number) – The lower bound of the interval. 
- to (number) – The upper bound of the interval. 
- generator (Generator, optional) – The random seed. Default: None. 
 
- Returns
- Tensor, with the same shape as tensor. 
- Raises
- TypeError – If from_ is larger than to. 
 - Supported Platforms:
- Ascend
 - Examples - >>> import mindspore >>> x = mindspore.ops.ones((4, 2)) >>> generator = mindspore.Generator() >>> generator.manual_seed(100) >>> output = x.uniform(1., 2., generator) >>> print(output.shape) (4, 2)