Skip to content

Use tf.reciprocal for backwards compatibility

Carla Marin Benito requested to merge cmarinbe-reciprocal into master

Use tf.reciprocal instead of tf.math.reciprocal since the latter is not available in old tf versions (1.11 or older).

tf.math.reciprocal was included in [tf 1.12[(https://github.com/tensorflow/docs/blob/r1.12/site/en/api_docs/python/tf/math/reciprocal.md) and is also available in the tf 2.X series but it is not defined for older versions (previous to 1.12). So it's usage in TFA prevents TFA from working with tf <1.12. The solution is to use tf.reciprocal instead, which was defined in the older tf versions and is an alias to tf.math.reciprocal in the new ones (tf > 1.11 and 2.X), precisely to allow for backwards compatible code.

This change should then be transparent for users of tf > 1.11 and 2.X and allow users of older versions to still use TFA.

Merge request reports