logspace

paddle. logspace ( start: float | paddle.Tensor, stop: float | paddle.Tensor, num: int | paddle.Tensor, base: float | paddle.Tensor = 10.0, dtype: DTypeLike | None = None, name: str | None = None ) paddle.Tensor [source]

Return fixed number of logarithmically-evenly spaced values within the interval \([base^{start}, base^{stop}]\).

Notes

This API does not compute the gradient.

Parameters
  • start (int|float|Tensor) – The input start is exponent of first entry in the sequence. It is a scalar, or a 0-D Tensor of shape [] with input data type int32, int64, float32 or float64.

  • stop (int|float|Tensor) – The input stop is exponent of last entry in the sequence. It is a scalar, or a 0-D Tensor of shape [] with input data type int32, int64, float32 or float64.

  • num (int|Tensor) – The input num is given number of items in the sequence. It is an int scalar, or a 0-D Tensor of shape [] with data type int32.

  • base (int|float|Tensor) – The input base is base of the logarithm function. It is a scalar, or a 0-D Tensor of shape [] with input data type int32, int64, float32 or float64.

  • dtype (np.dtype|str, optional) – The data type of output tensor, it could be int32, int64, float32 or float64. Default: if None, the data type is float32.

  • name (str|None, optional) – For details, please refer to Name. Generally, no setting is required. Default: None.

Returns

The output data type will be float32, float64. The 1-D tensor with fixed number of logarithmically-evenly spaced values, the data shape of this tensor is \([num]\). If the num is set 1, the output tensor just has the value with exponential of start with base base.

Return type

Tensor

Examples

>>> import paddle
>>> data = paddle.logspace(0, 10, 5, 2, 'float32')
>>> print(data.numpy())
[1.0000000e+00 5.6568542e+00 3.2000000e+01 1.8101933e+02 1.0240000e+03]
>>> data = paddle.logspace(0, 10, 1, 2, 'float32')
>>> print(data.numpy())
[1.]