Skip to content

AD (Zygote, ForwardDiff) compatibility? #91

Description

@scheidan

LabelledArrays looks very promising to simplify model definitions. Unfortunately it seem largely incompatible with AD. Is there a good workaround?

using LabelledArrays
import ForwardDiff
import Zygote

model(p) =  p.a + p.b^2 + p.c^3

p = LVector(a=1, b=2, c=3)
ps = SLVector(a=1, b=2, c=3)
model(ps)
model(p)

ForwardDiff.gradient(model, p) # works :)
Zygote.gradient(model, p)      # ERROR: ArgumentError: invalid index: Val{:c}() of type Val{:c}

ForwardDiff.gradient(model, ps) # ERROR: type SArray has no field a
Zygote.gradient(model, ps)      # ERROR: ArgumentError: invalid index: Val{:c}() of type Val{:c}

(In case of ForwardDiff this is probably related to #68)

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