mygrad.arange#
- mygrad.arange([start, ]stop, [step, ]dtype=None, *, constant=None)[source]#
Return a Tensor with evenly-spaced values within a given interval.
Values are generated within [start, stop). Note that for non-integer steps, results may be inconsistent; you are better off using linspace instead.
This docstring was adapted from
numpy.arange
[1]- Parameters:
- startReal, optional, default=0
The start of the interval, inclusive.
- stopReal
The end of the interval, exclusive.
- stepint, optional (default=1)
The spacing between successive values.
- dtypeOptional[DTypeLikeReals]
The data type of the output Tensor, or None to infer from the inputs.
- constantOptional[bool]
If
True
, this tensor is a constant, and thus does not facilitate back propagation.Defaults to
False
for float-type data. Defaults toTrue
for integer-type data.Integer-type tensors must be constant.
- Returns:
- Tensor
A Tensor of evenly-spaced values in [start, end).
References
[1]Retrieved from https://numpy.org/doc/stable/reference/generated/numpy.arange.html
Examples
>>> import mygrad as mg >>> mg.arange(3) Tensor([0, 1, 2]) >>> mg.arange(3.0, constant=True) # resulting tensor will not back-propagate a gradient Tensor([ 0., 1., 2.]) >>> mg.arange(3,7) Tensor([3, 4, 5, 6]) >>> mg.arange(3,7,2) Tensor([3, 5])