r""" Return fixed number of evenly spaced values within a given interval. Note: no gradient calculation is performed. Args: start(int|float|Tensor): The input :attr:`start` is start of range. It is a int, float, \ or a 0-D Tensor with data type int32, int64, float32 or f
(
start: float | paddle.Tensor,
stop: float | paddle.Tensor,
num: int | paddle.Tensor,
dtype: DTypeLike | None = None,
name: str | None = None,
*,
out: paddle.Tensor | None = None,
device: PlaceLike | None = None,
requires_grad: bool = False,
)
| 332 | |
| 333 | @param_two_alias(["stop", "end"], ["num", "steps"]) |
| 334 | def linspace( |
| 335 | start: float | paddle.Tensor, |
| 336 | stop: float | paddle.Tensor, |
| 337 | num: int | paddle.Tensor, |
| 338 | dtype: DTypeLike | None = None, |
| 339 | name: str | None = None, |
| 340 | *, |
| 341 | out: paddle.Tensor | None = None, |
| 342 | device: PlaceLike | None = None, |
| 343 | requires_grad: bool = False, |
| 344 | ) -> paddle.Tensor: |
| 345 | r""" |
| 346 | Return fixed number of evenly spaced values within a given interval. Note: no gradient calculation is performed. |
| 347 | |
| 348 | Args: |
| 349 | start(int|float|Tensor): The input :attr:`start` is start of range. It is a int, float, \ |
| 350 | or a 0-D Tensor with data type int32, int64, float32 or float64. |
| 351 | stop(int|float|Tensor): The input :attr:`stop` is end of range. It is a int, float, \ |
| 352 | or a 0-D Tensor with data type int32, int64, float32 or float64. |
| 353 | num(int|Tensor): The input :attr:`num` is given num of the sequence. It is an int, \ |
| 354 | or a 0-D Tensor with data type int32. |
| 355 | dtype(str|paddle.dtype|np.dtype|None, optional): The data type of output tensor, it could be |
| 356 | int32, int64, float32 and float64. Default: if None, the data type is float32. |
| 357 | name(str|None, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None. |
| 358 | out(Tensor|None, optional): Optional output tensor. If provided, the result will be stored in this tensor. \ |
| 359 | The tensor must have the correct shape and dtype. Default: None. |
| 360 | device(str|paddle.CUDAPlace|paddle.CPUPlace|None, optional): The device where the output tensor will be placed. \ |
| 361 | It can be a string (e.g., 'cpu', 'gpu:0'), a paddle.CUDAPlace, or a paddle.CPUPlace object. \ |
| 362 | If None, the current device context will be used. Default: None. |
| 363 | requires_grad(bool, optional): Whether the output tensor should have gradient computation enabled. \ |
| 364 | If True, the output tensor's ``stop_gradient`` attribute will be set to False. Default: False. |
| 365 | |
| 366 | Returns: |
| 367 | Tensor: the output data type will be float32, float64. The 1-D tensor with fixed number of evenly spaced values, \ |
| 368 | the data shape of this tensor is :math:`[num]` . If the :attr:`num` is set 1, the output tensor just has \ |
| 369 | the value with input :attr:`start`. |
| 370 | |
| 371 | .. note:: |
| 372 | **Alias Support:** |
| 373 | |
| 374 | - The parameter name ``end`` can be used as an alias for ``stop``. \ |
| 375 | For example, ``linspace(start=0, end=10, ...)`` is equivalent to ``linspace(start=0, stop=10, ...)``. |
| 376 | - The parameter name ``steps`` can be used as an alias for ``num``. \ |
| 377 | For example, ``linspace(start=0, stop=10, steps=5)`` is equivalent to ``linspace(start=0, stop=10, num=5)``. |
| 378 | |
| 379 | Examples: |
| 380 | .. code-block:: pycon |
| 381 | |
| 382 | >>> import paddle |
| 383 | >>> data = paddle.linspace(0, 10, 5, 'float32') |
| 384 | >>> print(data.numpy()) |
| 385 | [0. 2.5 5. 7.5 10.] |
| 386 | >>> data = paddle.linspace(0, 10, 1, 'float32') |
| 387 | >>> print(data.numpy()) |
| 388 | [0.] |
| 389 | |
| 390 | >>> # Using device parameter |
| 391 | >>> data = paddle.linspace(0, 10, 5, device='cpu') |
no test coverage detected