oneflow.linspace¶
-
oneflow.
linspace
(start: float, end: float, steps: int, dtype: oneflow._oneflow_internal.dtype = oneflow.float32, device: Optional[Union[str, oneflow._oneflow_internal.device]] = None, placement: Optional[oneflow._oneflow_internal.placement] = None, sbp: Optional[Union[oneflow._oneflow_internal.sbp.sbp, List[oneflow._oneflow_internal.sbp.sbp]]] = None, requires_grad: bool = False)¶ Creates a one-dimensional tensor of size
steps
whose values are evenly spaced fromstart
toend
, inclusive. That is, the value are:\[(\text{start}, \text{start} + \frac{\text{end} - \text{start}}{\text{steps} - 1}, \ldots, \text{start} + (\text{steps} - 2) * \frac{\text{end} - \text{start}}{\text{steps} - 1}, \text{end})\]- Parameters
- Keyword Arguments
dtype (flow.dtype, optional) – If dtype is not given, the dtype is inferred to be flow.float32.
device (flow.device, optional) – the desired device of returned tensor. Default: if None, uses the current device for the default tensor.
requires_grad (bool, optional) – If autograd should record operations on the returned tensor. Default: False.
For example:
>>> import oneflow as flow >>> y = flow.linspace(3, 10, steps=5) >>> y tensor([ 3.0000, 4.7500, 6.5000, 8.2500, 10.0000], dtype=oneflow.float32)