Custom Generative Functions

Gen provides scaffolding for custom (deterministic) generative functions that make use of either incremental computation or custom gradient updates.

Gen.CustomDetermGFType
CustomDetermGF{T,S} <: GenerativeFunction{T,CustomDetermGFTrace{T,S}}

Abstract type for a custom deterministic generative function.

source

Custom Incremental Computation

A CustomUpdateGF is a generative function that allows for easier implementation of custom incremental computation.

Gen.CustomUpdateGFType
CustomUpdateGF{T,S}

Abstract type for a generative function with a custom update computation, and default behaviors for all other generative function interface methods.

T is the type of the return value and S is the type of state used internally for incremental computation.

source
Gen.apply_with_stateFunction
retval, state = apply_with_state(gen_fn::CustomDetermGF, args)

Execute the generative function and return the return value and the state.

source
Gen.update_with_stateFunction
state, retval, retdiff = update_with_state(gen_fn::CustomDetermGF, state, args, argdiffs)

Update the arguments to the generative function and return new return value and state.

source

Custom Gradient Computations

A CustomGradientGF is a generative function that allows for easier implementation of custom gradients computations and updates.

Gen.CustomGradientGFType
CustomGradientGF{T}

Abstract type for a generative function with a custom gradient computation, and default behaviors for all other generative function interface methods.

T is the type of the return value.

source
Gen.applyFunction
retval = apply(gen_fn::CustomGradientGF, args)

Apply the function to the arguments.

source
Gen.gradientFunction
arg_grads = gradient(gen_fn::CustomDetermGF, args, retval, retgrad)

Return the gradient tuple with respect to the arguments, where nothing is for argument(s) whose gradient is not available.

source