`tf.reciprocal` 与 `tf.inv`:有什么区别吗?

`tf.reciprocal` vs `tf.inv`: is there any difference?

tf.reciprocaltf.inv 似乎是等价的。有什么不同吗?它们作为单独的 TF ops 实现,也有单独的渐变实现,这看起来也是等效的。

他们的意思是一样的。事实上,tf.inv 已重命名为 tf.reciprocal,并且 tf.inv 在最新版本中不再暴露给顶级模块(尽管两者仍然存在于 gen_math_ops.py 中)。

来自migration documentation:

Many functions have been renamed to match NumPy. This was done to make the transition between NumPy and TensorFlow as easy as possible. There are still numerous cases where functions do not match, so this is far from a hard and fast rule, but we have removed several commonly noticed inconsistencies.

  • tf.inv
    • should be renamed to tf.reciprocal
    • This was done to avoid confusion with NumPy's matrix inverse np.inv

您可以看到更多已重命名的函数,例如 tf.multf.neg