Defines a new op implementing a 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 represents the most generic definition of a new op representing a binary function, allowing the specification of: (1) the RawTensor operation, (2) the derivative propagation rule for the forward differentiation mode and (3) the derivative propagation rule for the reverse differentiation mode.
In general, if you are implementing a simple elementwise op, you should prefer using the BinaryOpElementwise type, which is much simpler to use.
{ new BinaryOp("matmul") with member _.fRaw(a,b) = a.MatMulTT(b) member _.ad_dfda(a,ad,b,f) = ad.matmul(b) member _.bd_dfdb(a,b,bd,f) = a.matmul(bd) member _.fd_dfda(a,b,f,fd) = fd.matmul(b.transpose()) member _.fd_dfdb(a,b,f,fd) = a.transposeExt().matmul(fd) }
Constructor | Description |
|
|
Instance member | Description |
Full Usage:
this.ad_dfda (a, ad, b, f)
Parameters:
Tensor
-
The first argument \( a \).
ad : Tensor
-
The first argument's derivative \( \frac{\partial a}{\partial x} \).
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 a}{\partial x} \frac{\partial f(a, b)}{\partial a} \).
Modifiers: abstract |
Derivative propagation rule for forward differentiation mode for the partial derivative with respect to the first argument of the function. This represents the contribution of the function's first argument \( a \) to the derivative of \( f(a, b) \) with respect a value \( x \) earlier in the computation graph than the function's arguments. In other words, it computes the first term in the right-hand side of the equation \( \frac{\partial f(a, b)}{\partial x} = \frac{\partial a}{\partial x} \frac{\partial f(a, b)}{\partial a} + \frac{\partial b}{\partial x} \frac{\partial f(a, b)}{\partial b} \).
|
Full Usage:
this.bd_dfdb (a, b, bd, f)
Parameters:
Tensor
-
The first argument \( a \).
b : Tensor
-
The second argument \( b \).
bd : Tensor
-
The second argument's derivative \( \frac{\partial b}{\partial x} \).
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 b}{\partial x} \frac{\partial f(a, b)}{\partial b} \).
Modifiers: abstract |
Derivative propagation rule for forward differentiation mode for the partial derivative with respect to the second argument of the function. This represents the contribution of the function's second argument \( b \) to the derivative of \( f(a, b) \) with respect a value \( x \) earlier in the computation graph than the function's arguments. In other words, it computes the second term in the right-hand side of the equation \( \frac{\partial f(a, b)}{\partial x} = \frac{\partial a}{\partial x} \frac{\partial f(a, b)}{\partial a} + \frac{\partial b}{\partial x} \frac{\partial f(a, b)}{\partial b} \).
|
|
|
Full Usage:
this.fd_dfda (a, b, f, fd)
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.
fd : Tensor
-
The derivative with respect to the function's output \( \frac{\partial y}{\partial f(a, b)} \).
Returns: Tensor
The tensor corresponding to \( \frac{\partial y}{\partial a} = \frac{\partial y}{\partial f(a, b)} \frac{\partial f(a, b)}{\partial a} \).
Modifiers: abstract |
Derivative propagation rule for reverse differentiation mode for the partial derivative with respect to the first argument of the function. This represents the derivative of a value \( y \), which comes later in the computation graph than the function's value \( f(a, b) \), with respect to the function's first argument \( a \). In other words, it computes \( \frac{\partial y}{\partial a} = \frac{\partial y}{\partial f(a, b)} \frac{\partial f(a, b)}{\partial a} \).
|
Full Usage:
this.fd_dfdb (a, b, f, fd)
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.
fd : Tensor
-
The derivative with respect to the function's output \( \frac{\partial y}{\partial f(a, b)} \).
Returns: Tensor
The tensor corresponding to \( \frac{\partial y}{\partial b} = \frac{\partial y}{\partial f(a, b)} \frac{\partial f(a, b)}{\partial b} \).
Modifiers: abstract |
Derivative propagation rule for reverse differentiation mode for the partial derivative with respect to the second argument of the function. This represents the derivative of a value \( y \), which comes later in the computation graph than the function's value \( f(a, b) \), with respect to the function's second argument \( b \). In other words, it computes \( \frac{\partial y}{\partial b} = \frac{\partial y}{\partial f(a, b)} \frac{\partial f(a, b)}{\partial b} \).
|
Full Usage:
this.name
Returns: string
|
|
© Copyright 2021, DiffSharp Contributors.