Custom Generative Functions

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

Gen.CustomDetermGF — Type
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.CustomUpdateGF — Type
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_state — Function
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_state — Function
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.CustomGradientGF — Type
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.apply — Function
retval = apply(gen_fn::CustomGradientGF, args)

Apply the function to the arguments.

source
Gen.gradient — Function
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