[英]tf.norm error ValueError: 'ord' must be a supported vector norm, got fro
I am trying to calculate the Frobenius Norm of my tensor 我正在尝试计算张量的Frobenius范数
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 ValueError:'ord'必须是支持的向量范数,来回
I don't understand why it is treating my 2D tensor as a vector and not as matrix. 我不明白为什么它将2D张量视为向量而不是矩阵。
Am I missing something here? 我在这里想念什么吗?
Thank you 谢谢
From the documentation : 从文档中 :
The Frobenius norm fro is not defined for vectors
未为向量定义Frobenius范数
Also, 也,
If axis is
None
(the default), the input is considered a vector如果axis为
None
(默认值),则将输入视为向量
Try this instead: 尝试以下方法:
tf.norm(temp, ord='fro', axis=(0,1))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.