-
-
Notifications
You must be signed in to change notification settings - Fork 617
Description
I have run into an issue when trying to take second derivatives of a chain of dense affine layers with respect to the input.
'u = Chain(
Dense(1,5, σ),
Dense(5, 1))`
There is no issue with taking a single derivative
du(x) = gradient(() -> sum(u(x)), params(x))
but if I try differentiating again,
ddu = gradient(params(x)) do sum(du(x)[x]) end
I get ERROR: Can't differentiate foreigncall expression . I would like to use flux to differentiate functions with respect to the input and later be able to compute the gradient with respect to the neural net parameters. I have been able to do this if I explicitly define all functions with respect to the input and each parameter but would like to use Flux's Chain() and Dense() functions. Should Flux be able to do this or am I reaching too far here? I am new to all this and trying to figure it out so I apologize if this has a straightforward solution that I am not getting.