Closed thearn closed 6 years ago
It looks like a bug. I was able to get a value that looks similar to the finite difference by replacing the +=
operators, e.g. ht_out = ht_out + ...
. Could you try to see if that fixes things for you? This would be just a temporary workaround, until we get to fix the bug.
Sure, I can use the workaround for now, I appreciate the feedback.
Definitely a bug, thanks for reporting it, and great catch! We were handling augmented assignments incorrectly in one of our pre-processing passes (anf.py). Should be fixed by #65 , which I hope to merge to master if tests pass.
One other nit, just an FYI for myself: it looks like trq
and the aug assign to ht_power
are unused in this calculation (it was the power += ...
statement that actually caused the gradient bug). Is that intentional, or an artifact of yanking code out of your codebase to give us a running example?
Yeah, It was originally a multi-output function that I tweaked just to get a running example. I may have more questions about best practices surrounding more specific use cases some time soon, but figured I would at least report this bug. Thanks again for the feedback!
Hi, I've been experimenting with this library for a few months now and really like the capabilities present. I'm working to develop an AD capability via code generation for a set of aerospace engineering codes in Python.
However, I think I've run into either a bug or a usage misunderstanding. Consider the following stand-alone function, which takes several parameters and returns a scalar:
If I generate the partial derivative of
power
with respect to the first parameterW_in
then I get:
Running this seems to give me a partial derivative of
0.0
regardless of the evaluation point. However, the partial is certainly non-zero, e.g. at (30., 30., 10., 9.5, 0.95, 1000., 1000., 1000., 999.) it would be about 0.67206, but insteadreturns 0.0.
The correct derivative of can be found analytically with some work, or confirmed roughly by finite difference:
Have I made a user error, or is this an unexpected bug? Thanks!