TorchLean API

NN.Spec.Autograd.Trigonometric

Trigonometric derivatives #

Sine and cosine act independently on each tensor entry, with angles measured in radians. Their Jacobians are diagonal, so the same pointwise derivative multiplication computes a JVP or a VJP. The scalar operations come from MathFunctions, which also supplies their derivatives when the scalar type is a dual number.

def Spec.sinOp {α : Type} [TorchLean.Storage α] [Context α] {s : Shape} :
OpSpec α s s

Elementwise sine with VJP cos(x) * dLdy.

Evaluating the cosine at the original input preserves its sign across periods; recovering it from the sine output would lose that information.

Instances For
    def Spec.cosOp {α : Type} [TorchLean.Storage α] [Context α] {s : Shape} :
    OpSpec α s s

    Elementwise cosine with VJP -sin(x) * dLdy, for inputs measured in radians.

    Instances For