Returns a 1-D tensor of size floor((end - start)/end)
with values from the interval [start, end) taken with common difference step beginning from start.
Note that non-integer step is subject to floating point rounding errors when comparing against end; to avoid inconsistency, we advise adding a small epsilon to
end in such cases.
tch_arange(start = 0, end = NULL, step = 1, out = NULL, dtype = NULL, layout = NULL, device = NULL, requires_grad = FALSE)
start | the starting value for the set of points |
---|---|
end | the ending value for the set of points |
step | the gap between each pair of adjacent points |
out | (optional) the output tensor |
dtype | the desired data type of returned tensor. Default: if None, uses a global default (see torch.set_default_tensor_type()). If dtype is not given, infer the data type from the other input arguments. If any of start, end, or stop are floating-point, the dtype is inferred to be the default dtype, see get_default_dtype(). Otherwise, the dtype is inferred to be torch.int64. |
layout | the desired layout of returned Tensor |
device | the desired device of returned tensor. Default: if None, uses the current device for the default tensor type (see torch.set_default_tensor_type()). device will be the CPU for CPU tensor types and the current CUDA device for CUDA tensor types |
requires_grad | boolean. If autograd should record operations on the returned tensor |
tch_arange(5)#> tensor #> 0 #> 1 #> 2 #> 3 #> 4 #> [ Variable[CPUFloatType]{5} ]tch_arange(1, 4)#> tensor #> 1 #> 2 #> 3 #> [ Variable[CPUFloatType]{3} ]tch_arange(1, 2.5, 0.5)#> tensor #> 1.0000 #> 1.5000 #> 2.0000 #> [ Variable[CPUFloatType]{3} ]