Defines a new op implementing an elementwise unary function and its derivatives. Instances of this class are used with the Tensor.Op method to define a new differentiable tensor function that supports forward, reverse, and nested differentiation.
This type is specialized to elementwise ops. It requires the user to specify only (1) the RawTensor operation and (2) the derivative of the function with respect to its argument. The corresponding derivative propagation rules for the forward and reverse differentiation modes are automatically generated.
If you are implementing a complex op that is not elementwise, you can use the generic type UnaryOp, which allows you to define the full derivative propagation rules.
{ new UnaryOpElementwise("cos") with member _.fRaw(a) = a.CosT() member _.dfda(a,f) = -a.sin() } { new UnaryOpElementwise("exp") with member _.fRaw(a) = a.ExpT() member _.dfda(a,f) = f } { new UnaryOpElementwise("log") with member _.fRaw(a) = a.LogT() member _.dfda(a,f) = 1/a }
Constructor | Description |
|
|
Instance member | Description |
Full Usage:
this.dfda (a, f)
Parameters:
Tensor
-
The argument \( a \)
f : Tensor
-
The function's pre-computed primal evaluation result \( f(a) \), which can be one of the terms involved in the derivative computation (e.g., the derivative of the exponential function) and be used without the need to recompute it.
Returns: Tensor
The tensor corresponding to \( \frac{\partial f(a)}{\partial a} \).
Modifiers: abstract |
|
© Copyright 2021, DiffSharp Contributors.