costisst
costisst

Reputation: 391

tf.norm error ValueError: 'ord' must be a supported vector norm, got fro

I am trying to calculate the Frobenius Norm of my tensor

W = tf.Variable(tf.random_normal([3072,20],stddev=0.1))
temp = tf.matmul(tf.transpose(W),W)
fro_W = tf.norm(temp, ord ='fro')

This produces the following error:

ValueError: 'ord' must be a supported vector norm, got fro

I don't understand why it is treating my 2D tensor as a vector and not as matrix.

Am I missing something here?

Thank you

Upvotes: 2

Views: 1816

Answers (1)

P-Gn
P-Gn

Reputation: 24591

From the documentation:

The Frobenius norm fro is not defined for vectors

Also,

If axis is None (the default), the input is considered a vector

Try this instead:

tf.norm(temp, ord='fro', axis=(0,1))

Upvotes: 4

Related Questions