捷徑

torch.linalg.vander

torch.linalg.vander(x, N=None) Tensor

生成 Vandermonde 矩陣。

返回 Vandermonde 矩陣 VV

V=(1x1x12x1N11x2x22x2N11x3x32x3N11xnxn2xnN1).V = \begin{pmatrix} 1 & x_1 & x_1^2 & \dots & x_1^{N-1}\\ 1 & x_2 & x_2^2 & \dots & x_2^{N-1}\\ 1 & x_3 & x_3^2 & \dots & x_3^{N-1}\\ \vdots & \vdots & \vdots & \ddots &\vdots \\ 1 & x_n & x_n^2 & \dots & x_n^{N-1} \end{pmatrix}.

針對 N > 1。如果 N= None,則 N = x.size(-1),因此輸出會是方形矩陣。

支援 float、double、cfloat、cdouble 和整數 dtype 的輸入。也支援向量批次,如果 x 是一個向量批次,則輸出會具有相同的批次維度。

numpy.vander 的差異

  • numpy.vander 不同,此函式會以遞增順序返回 x 的冪。若要以相反順序取得,請呼叫 linalg.vander(x, N).flip(-1)

參數

x (Tensor) – 形狀為 (*, n) 的張量,其中 * 是零或多個由向量組成的批次維度。

關鍵字參數

N (int, optional) – 輸出中的欄數。預設值:x.size(-1)

範例

>>> x = torch.tensor([1, 2, 3, 5])
>>> linalg.vander(x)
tensor([[  1,   1,   1,   1],
        [  1,   2,   4,   8],
        [  1,   3,   9,  27],
        [  1,   5,  25, 125]])
>>> linalg.vander(x, N=3)
tensor([[ 1,  1,  1],
        [ 1,  2,  4],
        [ 1,  3,  9],
        [ 1,  5, 25]])

文件

存取 PyTorch 的完整開發者文件

檢視文件

教學

取得適用於初學者和進階開發人員的深入教學

檢視教學

資源

尋找開發資源並獲得問題解答

檢視資源