fn

sqrt

Tensor
sqrt(input: Tensor)
source

Element-wise square root.

Computes the non-negative square root of each entry. Negative inputs produce NaN.

Parameters

inputTensor
Input tensor.

Returns

Tensor

Element-wise result with the same shape as input.

Notes

Mathematical definition:

outi=inputi,inputi0\text{out}_i = \sqrt{\text{input}_i}, \quad \text{input}_i \ge 0

Gradient: 1/(2x)1 / (2 \sqrt{x}). Diverges at x = 0.

Examples

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