評價此頁

torch.vander#

torch.vander(x, N=None, increasing=False) Tensor#

生成 Vandermonde 矩陣。

輸出矩陣的列是輸入向量的逐元素冪 x(N1),x(N2),...,x0x^{(N-1)}, x^{(N-2)}, ..., x^0. If increasing is True, the order of the columns is reversed x0,x1,...,x(N1)x^0, x^1, ..., x^{(N-1)}. 這種每一行都包含幾何級數的矩陣是以 Alexandre-Theophile Vandermonde 的名字命名的。

引數
  • x (Tensor) – 一維輸入張量。

  • N (int, optional) – 輸出的列數。如果未指定 N,則返回一個方陣 (N=len(x))(N = len(x))

  • increasing (bool, optional) – 列的冪的順序。如果為 True,則冪從左到右遞增;如果為 False(預設值),則冪是反向的。

返回

Vandermonde 矩陣。如果 increasing 為 False,則第一列是 x(N1)x^{(N-1)},第二列是 x(N2)x^{(N-2)},以此類推。如果 increasing 為 True,則列為 x0,x1,...,x(N1)x^0, x^1, ..., x^{(N-1)}

返回型別

張量

示例

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