Open roman-amici opened 4 years ago
Hi, @roman-amici
Apologize for the delayed response and I was trying to replicate the same issue from my end with latest @tensorflow/tfjs@4.10.0
and still it's throwing the same error message so we'll have dig more into this issue and will update you soon. Thank you!
CC :@pyu10055
Please refer below error screenshot :
To get help from the community, we encourage using Stack Overflow and the
tensorflow.js
tag.TensorFlow.js version
1.7.4
Browser version
Chrome Version 81.0.4044.138 (Official Build) (64-bit)
Describe the problem or feature request
Tensorflowjs appears to be able to take second derivatives with respect to most common functions. However, when exp, sigmoid, tanh, and presumably others are tried, it fails with the error
Cannot compute gradient of y=f(x) with respect to x. Make sure that the f you passed encloses all operations that lead from x to y.
Code to reproduce the bug / link to feature request
Consider a slight modification of the example code used for tf.grad in the api doc.
This gives the error above. With
gg(x).print()
line as the line causing the error.Note that if we just wanted the first derivative
works just fine. In the above code, if you change
tanh
tosinh
orcosh
or a number of other functions, this does work. The functions sigmoid and even exp all exhibit the same behavior.If you would like to get help from the community, we encourage using Stack Overflow and the
tensorflow.js
tag.GitHub issues for this repository are tracked in the tfjs union repository.
Please file your issue there, following the guidance in that issue template.