Flux loss: Gradient wrt input leads to empty gradient wrt parameters or to "can't differentiate foreigncall"

Thanks a lot for your answer! So the summary would be: I should wait for Diffract.jl if I want to compute this with AD, right? (Or isolate the error, but I feel like I am quite far from it…)

I figured out a “dirty” solution which is enough for my purposes by computing d(NN)/dx with finite difference. I am not proud of it but it does the job hahaha.

Anyway, if anyone has a solution for AD though, I’d still be highly interested!