lucid.arccos¶
The arccos function computes the element-wise inverse cosine of each element in the input tensor.
Function Signature¶
def arccos(a: Tensor) -> Tensor
Parameters¶
a (Tensor): The input tensor for which the inverse cosine is computed. Values should be in the range \([-1, 1]\).
Returns¶
- Tensor:
A new tensor containing the element-wise inverse cosine of the input tensor. If a requires gradients, the resulting tensor will also require gradients.
Forward Calculation¶
\[\mathbf{out}_i = \arccos(\mathbf{a}_i)\]
Backward Gradient Calculation¶
\[\frac{\partial \mathbf{out}_i}{\partial \mathbf{a}_i} = \frac{-1}{\sqrt{1 - \mathbf{a}_i^2}}\]
Example¶
>>> import lucid
>>> a = Tensor([0, 0.5, 1], requires_grad=True)
>>> out = lucid.arccos(a)
>>> print(out)
Tensor([1.57079633 1.04719755 0.], grad=None)