3

I need to use Hankel functions of the second kind, that is H_n^(2) with n in {0,1,2}, in Tensorflow. http://mathworld.wolfram.com/HankelFunctionoftheSecondKind.html

Tensorflow, however, does not have these functions in its standard library. It only offers modified Bessel functions of the first kind I0 and I1. https://www.tensorflow.org/api_docs/python/tf/math/bessel_i0 https://www.tensorflow.org/api_docs/python/tf/math/bessel_i1

I can maybe construct H_0(2) and H_1^(2) from I0 and I1, respectively, but what about H_2^(2)?

An alternative option I tested was calling scipy Hankel functions from Tensorflow but that doesn't ultimately work because the error cannot be back-propagated correctly through these non-Tensorflow functions.

Thus my question: has anyone sample code to implement H_n^(2) functions in Tensorflow or other recommendations/tricks?

Time2Lime
  • 61
  • 3
  • If a google search cannot find you anything, you might want to write a custom op (https://www.tensorflow.org/guide/extend/op) yourself in c++. I only see a boost implementation of this: https://www.boost.org/doc/libs/1_51_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/hankel/cyl_hankel.html. – greeness Jun 20 '19 at 01:40
  • I actually now think I could calculate everything in terms of I0 and I1, however that would require me to use complex inputs to I0 and I1 which is not allowed in TensorFlow. They say "Equivalent to scipy.special.i0" but scipy's version does accept complex inputs. So I don't know what to do with that. If I write libraries myself, I'd also have to define gradients myself, right? – Time2Lime Jun 20 '19 at 13:40
  • Yes. If you need gradient to backprop you need to provide its definition. – greeness Jun 20 '19 at 16:02

0 Answers0