mygrad.logspace#

mygrad.logspace(start: ArrayLike, stop: ArrayLike, num: int = 50, endpoint: bool = True, base: Union[int, float] = 10, dtype: Optional[DTypeLikeReals] = None, axis: int = 0, *, constant: Optional[bool] = None) Tensor[source]#

Return a Tensor with evenly-spaced numbers over a specified interval on a log scale. This is not a differentiable function - it does not propagate gradients to its inputs.

In linear space, values are generated within [base**start, base**stop], with the endpoint optionally excluded.

This docstring was adapted from numpy.logspace [1]

Parameters
startArrayLike

The starting value of the sequence, inclusive; start at base ** start.

stopArrayLike

The ending value of the sequence, inclusive unless include_endpoint is False; end at base ** stop.

numint, optional (default=50)

The number of values to generate. Must be non-negative.

endpointbool, optional (default=True)

Whether to include the endpoint in the Tensor. Note that if False, the step size changes to accommodate the sequence excluding the endpoint.

baseReal, optional (default=10)

The base of the log space.

dtypeOptional[DTypeLikeReals]

The data type of the output Tensor, or None to infer from the inputs.

axisint, optional (default=0)

The axis in the result to store the samples - for array-like start/stop.

constantOptional[bool]

If True, this tensor is a constant, and thus does not facilitate back propagation.

Defaults to False for float-type data. Defaults to True for integer-type data.

Integer-type tensors must be constant.

Returns
Tensor

See also

arange

Similar to linspace, with the step size specified instead of the number of samples. Note that, when used with a float endpoint, the endpoint may or may not be included.

linspace

Similar to logspace, but with the samples uniformly distributed in linear space, instead of log space.

geomspace

Similar to logspace, but with endpoints specified directly.

References

1

Retrieved from https://numpy.org/doc/stable/reference/generated/numpy.logspace.html

Examples

>>> import mygrad as mg
>>> mg.logspace(2.0, 3.0, num=4)
Tensor([  100.        ,   215.443469  ,   464.15888336,  1000.        ])
>>> mg.logspace(2.0, 3.0, num=4, endpoint=False)
Tensor([ 100.        ,  177.827941  ,  316.22776602,  562.34132519])
>>> mg.logspace(2.0, 3.0, num=4, base=2.0)
Tensor([ 4.        ,  5.0396842 ,  6.34960421,  8.        ])