codecamp

TensorFlow函数:tf.svd

tf.svd函数

别名:

  • tf.linalg.svd
  • tf.svd
tf.svd(
    tensor,
    full_matrices=False,
    compute_uv=True,
    name=None
)

定义在:tensorflow/python/ops/linalg_ops.py

请参阅指南:数学函数>矩阵数学函数

计算一个或多个矩阵的奇值分解.

计算 tensor 的每个内矩阵的 SVD,使得 tensor[..., :, :] = u[..., :, :] * diag(s[..., :, :]) * transpose(conj(v[..., :, :]))

# a is a tensor.
# s is a tensor of singular values.
# u is a tensor of left singular vectors.
# v is a tensor of right singular vectors.
s, u, v = svd(a)
s = svd(a, compute_uv=False)

函数参数:

  • tensor:具有形状 [..., M, N] 的 Tensor,让 P 成为最小的 M 和 N.
  • full_matrices:如果为 true,则计算全尺寸的 u 和 v;如果为 false(默认值),则只计算前导 P 奇向量;如果 compute_uv 为 False,则忽略.
  • compute_uv:如果为 True,则分别计算和返回在 u 和 v 中的左和右奇向量,否则,只会计算奇值,这可能会更快.
  • name:字符串,操作的可选名称.

函数返回值:

  • s:奇值;形状是 [..., P].这些值按相反的数量级排序,所以 s [...,0] 是最大的值,s [...,1] 是第二大的值,等等.
  • u:奇左向量;如果 full_matrices 为 False(默认),则形状是 [..., M, P];如果 full_matrices 为 True,那么形状为 [..., M, M].如果 compute_uv 为 False,则不会返回.
  • v:奇右向量.如果 full_matrices 为 False(默认),则形状是 [..., N, P].如果 full_matrices 为 True,则形状为 [..., N, N].如果 compute_uv 为 False,则不会返回.

NumPy的兼容性

主要等同于 numpy.linalg.svd, 只是输出参数的顺序在这里是 s, u, v 当 compute_uv 是真的, 而不是你, s, v 为 numpy.linalg.svd.* full_matrices 默认为 False, 而 numpy.linalg.svd 则为 True.* tf.linalg.svd 使用 svd 的标准定义 (a = U 西格玛 V ^ H), 这样, a 的左奇异向量是您的列, 而 a 的右奇异向量是 v 的列.另一方面, numpy.linalg.svd 将伴随 (V ^ H) 作为第三个输出参数返回.

TensorFlow:Summary类
TensorFlow函数:tf.tables_initializer
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

TensorFlow 函数介绍

TensorFlow 函数模块:tf

TensorFlow的image模块

TensorFlow使用之tf.io

TensorFlow使用之tf.keras

TensorFlow函数教程:tf.keras.applications

TensorFlow函数教程:tf.keras.backend

TensorFlow使用之tf.metrics

TensorFlow使用之tf.nn

TensorFlow使用之tf.python_io

TensorFlow 功能函数

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }