Description Usage Arguments Value Note Author(s) Examples
Initialize a new function that can be used by operators in a graph.
1 | cg_function(def, grads = list())
|
def |
function, the definition of the function. |
grads |
list of functions, the gradient functions with respect to each input (optional). |
cg_function object.
If the function consumes any inputs, then the gradient function with respect to these inputs must be provided to argument grads. These gradients must be a function of each input's gradient and take as arguments the inputs of the function including argument value and grad. These latter two arguments evaluate to the value of the function and its gradient respectively at run-time.
Ron Triepels
1 2 3 4 5 | #' # Create a custom negation function
f <- cg_function(
def = function(x) -x,
grads = list(function(x, value, grad) -grad)
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.