Skip to content

Can't differentiate foreigncall expression when trying to compute gradient #1338

@LucasPa

Description

@LucasPa

Hi,

I am beginner in Julia and I would like to use Flux. I tried to do the following:

using Flux
NN = Chain(Dense(1, 5, σ), Dense(5, 1, σ))

model(x) = NN([x])[1];
df(x) = gradient(model, x)[1]

function lossEq(x)
(df(x) - 2.0 * x - 3)^2
end

gs = gradient(() -> lossEq(0.2), params(NN))

But the following error is raised:

ERROR: Can't differentiate foreigncall expression

Is it actually possible to compute such a gradient that involves a gradient ?

Best,

Lucas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions