Defines a new op implementing an elementwise binary 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 each 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 BinaryOp, which allows you to define the full derivative propagation rules.
{ new BinaryOpElementwise("pow") with member _.fRaw(a,b) = a.PowTT(b) member _.dfda(a,b,f) = b * f / a member _.dfdb(a,b,f) = f * a.log() } { new BinaryOpElementwise("mul") with member _.fRaw(a,b) = a.MulTT(b) member _.dfda(a,b,f) = b member _.dfdb(a,b,f) = a }
Constructor | Description |
|
|
Instance member | Description |
Full Usage:
this.dfda (a, b, f)
Parameters:
Tensor
-
The first argument \( a \)
b : Tensor
-
The second argument \( b \)
f : Tensor
-
The function's pre-computed primal evaluation result \( f(a, b) \), 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, b)}{\partial a} \).
Modifiers: abstract |
Derivative of the function with respect to its first argument, \( \frac{\partial f(a, b)}{\partial a} \).
|
Full Usage:
this.dfdb (a, b, f)
Parameters:
Tensor
-
The first argument \( a \)
b : Tensor
-
The second argument \( b \)
f : Tensor
-
The function's pre-computed primal evaluation result \( f(a, b) \), 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, b)}{\partial b} \).
Modifiers: abstract |
Derivative of the function with respect to its second argument, \( \frac{\partial f(a, b)}{\partial b} \).
|
© Copyright 2021, DiffSharp Contributors.