fn
logspace
→Tensorlogspace(start: _float, end: _float, steps: _int, base: _float = 10.0, dtype: DTypeLike = None, device: DeviceLike = None)Return a 1-D tensor of steps values evenly spaced on a logarithmic scale.
Generates the geometric sequence
Equivalently, the exponents are linearly spaced (as in
linspace) and then the base is raised to those exponents. The
result spans the range multiplicatively: consecutive elements
satisfy .
Parameters
startfloatExponent of the first value. The first element equals
.
endfloatExponent of the last value. The last element equals
.
stepsintNumber of samples. Must be .
basefloatLogarithm base. Common choices:
10.0(default) — decades, used in frequency / magnitude plots2.0— octaves, used in learning-rate schedules and waveletsmath.e() — natural exponential spacing
dtypelucid.dtypeScalar data type. Defaults to the global default float dtype.
devicestr or lucid.deviceTarget device —
"cpu" or "metal".Returns
Tensor1-D tensor of shape (steps,) with geometrically spaced values.
Notes
Logarithmic spacing appears in:
- Learning-rate grid search — scanning
with
logspace(-5, -1, 9)covers five decades uniformly in log-space rather than concentrating samples near the upper bound as linear spacing would. - Frequency analysis — the mel and bark scales approximate human auditory perception and are nearly logarithmic in Hz.
- Sinusoidal position encodings (Vaswani et al., 2017) use , which is a logspace on base .
The ratio between adjacent elements is constant:
Examples
>>> import lucid
>>> lucid.logspace(0, 3, 4).tolist()
[1.0, 10.0, 100.0, 1000.0]
Two-octave learning-rate sweep (base 2):
>>> lrs = lucid.logspace(-8, -1, 8, base=2.0)
>>> lrs.tolist()
[0.00390625, 0.0078125, ..., 0.5]
Sinusoidal position encoding frequencies (Transformer convention):
>>> d_model = 512
>>> inv_freq = lucid.logspace(0, -1, d_model // 2, base=10000.0)