fn

log2

Tensor
log2(input: Tensor)
source

Element-wise base-2 logarithm.

Computes log2(x)\log_2(x) for each entry. The input must be strictly positive.

Parameters

inputTensor
Input tensor.

Returns

Tensor

Element-wise result with the same shape as input.

Notes

Mathematical definition:

outi=log2(inputi)\text{out}_i = \log_2(\text{input}_i)

Gradient: 1/(xln2)1 / (x \ln 2).

Examples

>>> import lucid
>>> x = lucid.tensor([1.0, 2.0, 3.0])
>>> lucid.log2(x)
Tensor([...])