Custom Generative Functions
Gen provides scaffolding for custom (deterministic) generative functions that make use of either incremental computation or custom gradient updates.
Gen.CustomDetermGF
— TypeCustomDetermGF{T,S} <: GenerativeFunction{T,CustomDetermGFTrace{T,S}}
Abstract type for a custom deterministic generative function.
Gen.CustomDetermGFTrace
— TypeCustomDetermGFTrace{T,S} <: Trace
Trace type for custom deterministic generative function.
Custom Incremental Computation
A CustomUpdateGF
is a generative function that allows for easier implementation of custom incremental computation.
Gen.CustomUpdateGF
— TypeCustomUpdateGF{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.
Gen.apply_with_state
— Functionretval, state = apply_with_state(gen_fn::CustomDetermGF, args)
Execute the generative function and return the return value and the state.
Gen.update_with_state
— Functionstate, 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.
Gen.num_args
— Functionnum_args(::CustomUpdateGF)
Returns the number of arguments.
Custom Gradient Computations
A CustomGradientGF
is a generative function that allows for easier implementation of custom gradients computations and updates.
Gen.CustomGradientGF
— TypeCustomGradientGF{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.
Gen.apply
— Functionretval = apply(gen_fn::CustomGradientGF, args)
Apply the function to the arguments.
Gen.gradient
— Functionarg_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.