Skip to content

ADing through set_scalar_constants! #146

@ArnoStrouwen

Description

@ArnoStrouwen

I'm performing Bayesian analysis on the parameters of a tree (with Turing.jl).
This requires calculating gradients with regards to these parameters.
Currently, I have to intercept the Dual numbers and manually construct the Jacobean, which is a bit cumbersome.

    y_sim = if eltype(a_b_vals) == Float64
        set_scalar_constants!(tree, a_b_vals, a_b_nodes)
        eval_tree_array(tree, X, operators)[1]
    else
        set_scalar_constants!(tree, ForwardDiff.value.(a_b_vals), a_b_nodes)
        val, grad = eval_grad_tree_array(tree, X, operators, variable=false)
        [ForwardDiff.Dual{ForwardDiff.tagtype(a_b_vals[1])}(val[i], 0.0, grad[:, i]...) for i in eachindex(val)]
    end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions