Learn R Programming

cgraph (version 6.0.1)

cg_function: Create function

Description

Initialize a new function that can be used by operators in a graph.

Usage

cg_function(def, grads = list())

Arguments

def

function, the definition of the function.

grads

list of functions, the gradient functions with respect to each input (optional).

Value

cg_function object.

Examples

Run this code
# NOT RUN {
#' # Create a custom negation function
f <- cg_function(
    def = function(x) -x,
    grads = list(function(x, value, grad) -grad)
)

# }

Run the code above in your browser using DataLab