mindspore.numpy.geomspace
- mindspore.numpy.geomspace(start, stop, num=50, endpoint=True, dtype=None, axis=0)[源代码]
Returns numbers spaced evenly on a log scale (a geometric progression).
This is similar to logspace, but with endpoints specified directly. Each output sample is a constant multiple of the previous.
- 参数
start (Union[int, list(int), tuple(int), tensor]) – The starting value of the sequence.
stop (Union[int, list(int), tuple(int), tensor]) – The final value of the sequence, unless endpoint is False. In that case, num + 1 values are spaced over the interval in log-space, of which all but the last (a sequence of length num) are returned.
num (int, optional) – Number of samples to generate. Default:
50
.endpoint (bool, optional) – If True, stop is the last sample. Otherwise, it is not included. Default:
True
.dtype (Union[
mindspore.dtype
, str], optional) – Designated tensor dtype, can be in format of np.float32, or float32.If dtype is None, infer the data type from other input arguments. Default:None
.axis (int, optional) – The axis in the result to store the samples. Relevant only if start or stop is array-like. By default (0), the samples will be along a new axis inserted at the beginning. Use -1 to get an axis at the end. Default:
0
.
- 返回
Tensor, with samples equally spaced on a log scale.
- 异常
TypeError – If input arguments have types not specified above.
- Supported Platforms:
Ascend
GPU
CPU
样例
>>> import mindspore.numpy as np >>> output = np.geomspace(1, 256, num=9) >>> print(output) [ 1. 2. 4. 8. 16. 32. 64. 128. 256.] >>> output = np.geomspace(1, 256, num=8, endpoint=False) >>> print(output) [ 1. 2. 4. 8. 16. 32. 64. 128.]