Conchylicultor
Conchylicultor

Reputation: 5719

Equivalent of numpy.linalg.norm for TensorFlow

After searching a while, I could not find a function to compute the l2 norm of a tensor. It seems really strange for me that it's not included so I'm probably missing something.

I looked at the l2_normalize and tf.clip_by_norm implementations and all use rsqrt(reduce_sum(x**2)) to do the trick (in that case inverse norm).

I'm probably missing something or is there a reason for not including such common function as a standard operator ?

Edit: a relevant issue from one years ago: https://github.com/tensorflow/tensorflow/issues/424

Upvotes: 0

Views: 2363

Answers (1)

Yaroslav Bulatov
Yaroslav Bulatov

Reputation: 57923

This has been added as tf.norm(matrix, order="fro") in commit 709fa61b

Upvotes: 3

Related Questions