捷徑

torch.special

torch.special 模組,以 SciPy 的 special 模組為模型。

函式

torch.special.airy_ai(input, *, out=None) Tensor

艾里函數 Ai(input)\text{Ai}\left(\text{input}\right)

參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

torch.special.bessel_j0(input, *, out=None) Tensor

00 階第一類貝索函數。

參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

torch.special.bessel_j1(input, *, out=None) Tensor

11 階第一類貝索函數。

參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

torch.special.digamma(input, *, out=None) Tensor

計算輸入上伽瑪函數的對數導數。

ϝ(x)=ddxln(Γ(x))=Γ(x)Γ(x)\digamma(x) = \frac{d}{dx} \ln\left(\Gamma\left(x\right)\right) = \frac{\Gamma'(x)}{\Gamma(x)}
參數

輸入 (張量) – 要計算雙伽瑪函數的張量

關鍵字參數

out (Tensor, optional) – 輸出張量。

注意事項

此函數類似於 SciPy 的 scipy.special.digamma

注意事項

從 PyTorch 1.8 版本開始,雙伽瑪函數在 0 時傳回 -Inf。先前版本在 0 時傳回 NaN

範例

>>> a = torch.tensor([1, 0.5])
>>> torch.special.digamma(a)
tensor([-0.5772, -1.9635])
torch.special.entr(input, *, out=None) 張量

逐元素計算 input 上的熵(定義如下)。

entr(x)={xln(x)x>00x=0.0x<0\begin{align} \text{entr(x)} = \begin{cases} -x * \ln(x) & x > 0 \\ 0 & x = 0.0 \\ -\infty & x < 0 \end{cases} \end{align}
參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例:
>>> a = torch.arange(-0.5, 1, 0.5)
>>> a
tensor([-0.5000,  0.0000,  0.5000])
>>> torch.special.entr(a)
tensor([  -inf, 0.0000, 0.3466])
torch.special.erf(input, *, out=None) 張量

計算 input 的誤差函數。誤差函數的定義如下:

erf(x)=2π0xet2dt\mathrm{erf}(x) = \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^2} dt
參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> torch.special.erf(torch.tensor([0, -1., 10.]))
tensor([ 0.0000, -0.8427,  1.0000])
torch.special.erfc(input, *, out=None) Tensor

計算 input 的餘誤差函數。餘誤差函數的定義如下

erfc(x)=12π0xet2dt\mathrm{erfc}(x) = 1 - \frac{2}{\sqrt{\pi}} \int_{0}^{x} e^{-t^2} dt
參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> torch.special.erfc(torch.tensor([0, -1., 10.]))
tensor([ 1.0000, 1.8427,  0.0000])
torch.special.erfcx(input, *, out=None) Tensor

計算 input 中每個元素的縮放餘誤差函數。縮放餘誤差函數的定義如下

erfcx(x)=ex2erfc(x)\mathrm{erfcx}(x) = e^{x^2} \mathrm{erfc}(x)
參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> torch.special.erfcx(torch.tensor([0, -1., 10.]))
tensor([ 1.0000, 5.0090, 0.0561])
torch.special.erfinv(input, *, out=None) Tensor

計算 input 的逆誤差函數。逆誤差函數在 (1,1)(-1, 1) 範圍內定義為

erfinv(erf(x))=x\mathrm{erfinv}(\mathrm{erf}(x)) = x
參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> torch.special.erfinv(torch.tensor([0, 0.5, -1.]))
tensor([ 0.0000,  0.4769,    -inf])
torch.special.exp2(input, *, out=None) Tensor

計算 input 的以 2 為底的指數函數。

yi=2xiy_{i} = 2^{x_{i}}
參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> torch.special.exp2(torch.tensor([0, math.log2(2.), 3, 4]))
tensor([ 1.,  2.,  8., 16.])
torch.special.expit(input, *, out=None) Tensor

計算 input 元素的 expit(也稱為邏輯 sigmoid 函數)。

outi=11+einputi\text{out}_{i} = \frac{1}{1 + e^{-\text{input}_{i}}}
參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> t = torch.randn(4)
>>> t
tensor([ 0.9213,  1.0887, -0.8858, -1.7683])
>>> torch.special.expit(t)
tensor([ 0.7153,  0.7481,  0.2920,  0.1458])
torch.special.expm1(input, *, out=None) Tensor

計算 input 元素的指數減 1。

yi=exi1y_{i} = e^{x_{i}} - 1

注意事項

對於較小的 x 值,此函數提供的精度優於 exp(x) - 1。

參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> torch.special.expm1(torch.tensor([0, math.log(2.)]))
tensor([ 0.,  1.])
torch.special.gammainc(input, other, *, out=None) Tensor

計算正規化的下不完全伽瑪函數

outi=1Γ(inputi)0otheritinputi1etdt\text{out}_{i} = \frac{1}{\Gamma(\text{input}_i)} \int_0^{\text{other}_i} t^{\text{input}_i-1} e^{-t} dt

其中 inputi\text{input}_iotheri\text{other}_i 皆為弱正數,且至少其中一個為嚴格正數。如果兩者皆為零,或其中一個為負數,則 outi=nan\text{out}_i=\text{nan}。上述公式中的 Γ()\Gamma(\cdot) 是伽瑪函數,

Γ(inputi)=0t(inputi1)etdt.\Gamma(\text{input}_i) = \int_0^\infty t^{(\text{input}_i-1)} e^{-t} dt.

相關函數請參閱 torch.special.gammaincc()torch.special.gammaln()

支援 廣播到相同形狀 和浮點數輸入。

注意事項

目前尚不支援針對 input 的反向傳播。請在 PyTorch 的 Github 上提出 issue 以提出請求。

參數
  • input (Tensor) – 第一個非負輸入張量

  • other (Tensor) – 第二個非負輸入張量

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> a1 = torch.tensor([4.0])
>>> a2 = torch.tensor([3.0, 4.0, 5.0])
>>> a = torch.special.gammaincc(a1, a2)
tensor([0.3528, 0.5665, 0.7350])
tensor([0.3528, 0.5665, 0.7350])
>>> b = torch.special.gammainc(a1, a2) + torch.special.gammaincc(a1, a2)
tensor([1., 1., 1.])
torch.special.gammaincc(input, other, *, out=None) Tensor

計算正規化的上不完全伽瑪函數

outi=1Γ(inputi)otheritinputi1etdt\text{out}_{i} = \frac{1}{\Gamma(\text{input}_i)} \int_{\text{other}_i}^{\infty} t^{\text{input}_i-1} e^{-t} dt

其中 inputi\text{input}_iotheri\text{other}_i 皆為弱正數,且至少其中一個為嚴格正數。如果兩者皆為零,或其中一個為負數,則 outi=nan\text{out}_i=\text{nan}。上述公式中的 Γ()\Gamma(\cdot) 是伽瑪函數,

Γ(inputi)=0t(inputi1)etdt.\Gamma(\text{input}_i) = \int_0^\infty t^{(\text{input}_i-1)} e^{-t} dt.

相關函數請參閱 torch.special.gammainc()torch.special.gammaln()

支援 廣播到相同形狀 和浮點數輸入。

注意事項

目前尚不支援針對 input 的反向傳播。請在 PyTorch 的 Github 上提出 issue 以提出請求。

參數
  • input (Tensor) – 第一個非負輸入張量

  • other (Tensor) – 第二個非負輸入張量

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> a1 = torch.tensor([4.0])
>>> a2 = torch.tensor([3.0, 4.0, 5.0])
>>> a = torch.special.gammaincc(a1, a2)
tensor([0.6472, 0.4335, 0.2650])
>>> b = torch.special.gammainc(a1, a2) + torch.special.gammaincc(a1, a2)
tensor([1., 1., 1.])
torch.special.gammaln(input, *, out=None) Tensor

計算 input 上伽瑪函數的絕對值的自然對數。

outi=lnΓ(inputi)\text{out}_{i} = \ln \Gamma(|\text{input}_{i}|)
參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> a = torch.arange(0.5, 2, 0.5)
>>> torch.special.gammaln(a)
tensor([ 0.5724,  0.0000, -0.1208])
torch.special.i0(input, *, out=None) Tensor

計算 input 中每個元素的第一類零階修正貝索函數。

outi=I0(inputi)=k=0(inputi2/4)k(k!)2\text{out}_{i} = I_0(\text{input}_{i}) = \sum_{k=0}^{\infty} \frac{(\text{input}_{i}^2/4)^k}{(k!)^2}
參數

input (Tensor) – 輸入張量

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> torch.i0(torch.arange(5, dtype=torch.float32))
tensor([ 1.0000,  1.2661,  2.2796,  4.8808, 11.3019])
torch.special.i0e(input, *, out=None) Tensor

計算 input 中每個元素的指數縮放第一類零階修正貝索函數(如下定義)。

outi=exp(x)i0(x)=exp(x)k=0(inputi2/4)k(k!)2\text{out}_{i} = \exp(-|x|) * i0(x) = \exp(-|x|) * \sum_{k=0}^{\infty} \frac{(\text{input}_{i}^2/4)^k}{(k!)^2}
參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例:
>>> torch.special.i0e(torch.arange(5, dtype=torch.float32))
tensor([1.0000, 0.4658, 0.3085, 0.2430, 0.2070])
torch.special.i1(input, *, out=None) Tensor

計算 input 中每個元素的第一類一階修正貝索函數(定義如下)。

outi=(inputi)2k=0(inputi2/4)k(k!)(k+1)!\text{out}_{i} = \frac{(\text{input}_{i})}{2} * \sum_{k=0}^{\infty} \frac{(\text{input}_{i}^2/4)^k}{(k!) * (k+1)!}
參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例:
>>> torch.special.i1(torch.arange(5, dtype=torch.float32))
tensor([0.0000, 0.5652, 1.5906, 3.9534, 9.7595])
torch.special.i1e(input, *, out=None) Tensor

計算 input 中每個元素的指數縮放後的第一類一階修正貝索函數(定義如下)。

outi=exp(x)i1(x)=exp(x)(inputi)2k=0(inputi2/4)k(k!)(k+1)!\text{out}_{i} = \exp(-|x|) * i1(x) = \exp(-|x|) * \frac{(\text{input}_{i})}{2} * \sum_{k=0}^{\infty} \frac{(\text{input}_{i}^2/4)^k}{(k!) * (k+1)!}
參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例:
>>> torch.special.i1e(torch.arange(5, dtype=torch.float32))
tensor([0.0000, 0.2079, 0.2153, 0.1968, 0.1788])
torch.special.log1p(input, *, out=None) Tensor

torch.log1p() 的別名。

torch.special.log_ndtr(input, *, out=None) Tensor

計算標準高斯機率密度函數下,從負無窮積分到 input 的面積對數,以元素為單位。

log_ndtr(x)=log(12πxe12t2dt)\text{log\_ndtr}(x) = \log\left(\frac{1}{\sqrt{2 \pi}}\int_{-\infty}^{x} e^{-\frac{1}{2}t^2} dt \right)
參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例:
>>> torch.special.log_ndtr(torch.tensor([-3., -2, -1, 0, 1, 2, 3]))
tensor([-6.6077 -3.7832 -1.841  -0.6931 -0.1728 -0.023  -0.0014])
torch.special.log_softmax(input, dim, *, dtype=None) Tensor

計算 softmax 後接著取對數。

雖然數學上等同於 log(softmax(x)),但分別執行這兩個運算速度較慢且數值不穩定。此函數計算如下:

log_softmax(xi)=log(exp(xi)jexp(xj))\text{log\_softmax}(x_{i}) = \log\left(\frac{\exp(x_i) }{ \sum_j \exp(x_j)} \right)
參數
  • input (Tensor) – 輸入

  • dim (int) – 沿其計算 log_softmax 的維度。

  • dtype (torch.dtype, optional) – 返回張量的所需數據類型。如果指定,則在執行操作之前將輸入張量轉換為 dtype。這對於防止數據類型溢出很有用。默認值:無。

範例:
>>> t = torch.ones(2, 2)
>>> torch.special.log_softmax(t, 0)
tensor([[-0.6931, -0.6931],
        [-0.6931, -0.6931]])
torch.special.logit(input, eps=None, *, out=None) Tensor

返回一個新張量,其中包含 input 元素的邏輯函數值。當 eps 不為 None 時,input 會被限制在 [eps, 1 - eps] 的範圍內。當 eps 為 None 且 input < 0 或 input > 1 時,函數將會產生 NaN。

yi=ln(zi1zi)zi={xiif eps is Noneepsif xi<epsxiif epsxi1eps1epsif xi>1eps\begin{align} y_{i} &= \ln(\frac{z_{i}}{1 - z_{i}}) \\ z_{i} &= \begin{cases} x_{i} & \text{if eps is None} \\ \text{eps} & \text{if } x_{i} < \text{eps} \\ x_{i} & \text{if } \text{eps} \leq x_{i} \leq 1 - \text{eps} \\ 1 - \text{eps} & \text{if } x_{i} > 1 - \text{eps} \end{cases} \end{align}
參數
  • input (Tensor) – 輸入張量。

  • eps (float, 選項) – 輸入夾緊邊界的 epsilon 值。 預設值:None

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> a = torch.rand(5)
>>> a
tensor([0.2796, 0.9331, 0.6486, 0.1523, 0.6516])
>>> torch.special.logit(a, eps=1e-6)
tensor([-0.9466,  2.6352,  0.6131, -1.7169,  0.6261])
torch.special.logsumexp(input, dim, keepdim=False, *, out=None)

torch.logsumexp() 的別名。

torch.special.multigammaln(input, p, *, out=None) Tensor

以元素方式計算維度為 pp多變量對數Γ函數,由下式給出

log(Γp(a))=C+i=1plog(Γ(ai12))\log(\Gamma_{p}(a)) = C + \displaystyle \sum_{i=1}^{p} \log\left(\Gamma\left(a - \frac{i - 1}{2}\right)\right)

其中 C=log(π)p(p1)4C = \log(\pi) \cdot \frac{p (p - 1)}{4}Γ()\Gamma(-) 為 Gamma 函數。

所有元素都必須大於 p12\frac{p - 1}{2},否則行為未定義。

參數
  • 輸入 (張量) – 要計算多變量對數 Gamma 函數的張量

  • p (整數) – 維度數

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> a = torch.empty(2, 3).uniform_(1, 2)
>>> a
tensor([[1.6835, 1.8474, 1.1929],
        [1.0475, 1.7162, 1.4180]])
>>> torch.special.multigammaln(a, 2)
tensor([[0.3928, 0.4007, 0.7586],
        [1.0311, 0.3901, 0.5049]])
torch.special.ndtr(輸入, *, 輸出=) 張量

計算標準高斯機率密度函數下的面積,從負無窮大積分到 輸入,以元素為單位。

ndtr(x)=12πxe12t2dt\text{ndtr}(x) = \frac{1}{\sqrt{2 \pi}}\int_{-\infty}^{x} e^{-\frac{1}{2}t^2} dt
參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例:
>>> torch.special.ndtr(torch.tensor([-3., -2, -1, 0, 1, 2, 3]))
tensor([0.0013, 0.0228, 0.1587, 0.5000, 0.8413, 0.9772, 0.9987])
torch.special.ndtri(輸入, *, 輸出=) 張量

計算參數 x,使得高斯機率密度函數下的面積(從負無窮大積分到 x)等於 輸入,以元素為單位。

ndtri(p)=2erf1(2p1)\text{ndtri}(p) = \sqrt{2}\text{erf}^{-1}(2p - 1)

注意事項

也稱為常態分配的分位數函數。

參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例:
>>> torch.special.ndtri(torch.tensor([0, 0.25, 0.5, 0.75, 1]))
tensor([   -inf, -0.6745,  0.0000,  0.6745,     inf])
torch.special.polygamma(n, input, *, out=None) Tensor

計算 input 上的雙伽瑪函數的 nthn^{th} 階導數。 n0n \geq 0 稱為多伽瑪函數的階數。

ψ(n)(x)=d(n)dx(n)ψ(x)\psi^{(n)}(x) = \frac{d^{(n)}}{dx^{(n)}} \psi(x)

注意事項

此函數僅針對非負整數 n0n \geq 0 實作。

參數
  • n (int) – 多伽瑪函數的階數

  • input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例:
>>> a = torch.tensor([1, 0.5])
>>> torch.special.polygamma(1, a)
tensor([1.64493, 4.9348])
>>> torch.special.polygamma(2, a)
tensor([ -2.4041, -16.8288])
>>> torch.special.polygamma(3, a)
tensor([ 6.4939, 97.4091])
>>> torch.special.polygamma(4, a)
tensor([ -24.8863, -771.4742])
torch.special.psi(input, *, out=None) Tensor

torch.special.digamma() 的別名。

torch.special.round(input, *, out=None) Tensor

torch.round() 的別名。

torch.special.scaled_modified_bessel_k0(input, *, out=None) Tensor

第二類 00 階比例修正貝索函數。

參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

torch.special.scaled_modified_bessel_k1(input, *, out=None) Tensor

第二類 11 階比例修正貝索函數。

參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

torch.special.sinc(input, *, out=None) Tensor

計算 input 的正規化 sinc。

outi={1,if inputi=0sin(πinputi)/(πinputi),otherwise\text{out}_{i} = \begin{cases} 1, & \text{if}\ \text{input}_{i}=0 \\ \sin(\pi \text{input}_{i}) / (\pi \text{input}_{i}), & \text{otherwise} \end{cases}
參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例:
>>> t = torch.randn(4)
>>> t
tensor([ 0.2252, -0.2948,  1.0267, -1.1566])
>>> torch.special.sinc(t)
tensor([ 0.9186,  0.8631, -0.0259, -0.1300])
torch.special.softmax(input, dim, *, dtype=None) Tensor

計算 softmax 函數。

Softmax 的定義如下:

Softmax(xi)=exp(xi)jexp(xj)\text{Softmax}(x_{i}) = \frac{\exp(x_i)}{\sum_j \exp(x_j)}

它會套用到沿著 dim 的所有切片,並重新調整它們,讓元素位於 [0, 1] 範圍內,且總和為 1。

參數
  • input (Tensor) – 輸入

  • dim (int) – 計算 softmax 的維度。

  • dtype (torch.dtype, optional) – 返回張量的所需數據類型。如果指定,則在執行操作之前將輸入張量轉換為 dtype。這對於防止數據類型溢出很有用。默認值:無。

範例:
>>> t = torch.ones(2, 2)
>>> torch.special.softmax(t, 0)
tensor([[0.5000, 0.5000],
        [0.5000, 0.5000]])
torch.special.spherical_bessel_j0(input, *, out=None) Tensor

第一類 00 階球貝索函數。

參數

input (Tensor) – 輸入張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

torch.special.xlog1py(input, other, *, out=None) Tensor

計算 input * log1p(other),包含以下情況。

outi={NaNif otheri=NaN0if inputi=0.0 and otheri!=NaNinputilog1p(otheri)otherwise\text{out}_{i} = \begin{cases} \text{NaN} & \text{if } \text{other}_{i} = \text{NaN} \\ 0 & \text{if } \text{input}_{i} = 0.0 \text{ and } \text{other}_{i} != \text{NaN} \\ \text{input}_{i} * \text{log1p}(\text{other}_{i})& \text{otherwise} \end{cases}

與 SciPy 的 scipy.special.xlog1py 相似。

參數
  • 輸入數字張量) – 乘數

  • 其他數字張量) – 參數

注意事項

輸入其他 至少要有一個是張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> x = torch.zeros(5,)
>>> y = torch.tensor([-1, 0, 1, float('inf'), float('nan')])
>>> torch.special.xlog1py(x, y)
tensor([0., 0., 0., 0., nan])
>>> x = torch.tensor([1, 2, 3])
>>> y = torch.tensor([3, 2, 1])
>>> torch.special.xlog1py(x, y)
tensor([1.3863, 2.1972, 2.0794])
>>> torch.special.xlog1py(x, 4)
tensor([1.6094, 3.2189, 4.8283])
>>> torch.special.xlog1py(2, y)
tensor([2.7726, 2.1972, 1.3863])
torch.special.xlogy(輸入, 其他, *, 輸出=) 張量

計算 輸入 * log(其他),並考慮以下情況。

outi={NaNif otheri=NaN0if inputi=0.0inputilog(otheri)otherwise\text{out}_{i} = \begin{cases} \text{NaN} & \text{if } \text{other}_{i} = \text{NaN} \\ 0 & \text{if } \text{input}_{i} = 0.0 \\ \text{input}_{i} * \log{(\text{other}_{i})} & \text{otherwise} \end{cases}

類似於 SciPy 的 scipy.special.xlogy

參數
  • 輸入數字張量) – 乘數

  • 其他數字張量) – 參數

注意事項

輸入其他 至少要有一個是張量。

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例

>>> x = torch.zeros(5,)
>>> y = torch.tensor([-1, 0, 1, float('inf'), float('nan')])
>>> torch.special.xlogy(x, y)
tensor([0., 0., 0., 0., nan])
>>> x = torch.tensor([1, 2, 3])
>>> y = torch.tensor([3, 2, 1])
>>> torch.special.xlogy(x, y)
tensor([1.0986, 1.3863, 0.0000])
>>> torch.special.xlogy(x, 4)
tensor([1.3863, 2.7726, 4.1589])
>>> torch.special.xlogy(2, y)
tensor([2.1972, 1.3863, 0.0000])
torch.special.zeta(input, other, *, out=None) Tensor

逐元素計算赫維茨 ζ 函數。

ζ(x,q)=k=01(k+q)x\zeta(x, q) = \sum_{k=0}^{\infty} \frac{1}{(k + q)^x}
參數
  • input (Tensor) – 對應於 x 的輸入張量。

  • other (Tensor) – 對應於 q 的輸入張量。

注意事項

黎曼 ζ 函數對應於 q = 1 的情況

關鍵字參數

out (Tensor, optional) – 輸出張量。

範例:
>>> x = torch.tensor([2., 4.])
>>> torch.special.zeta(x, 1)
tensor([1.6449, 1.0823])
>>> torch.special.zeta(x, torch.tensor([1., 2.]))
tensor([1.6449, 0.0823])
>>> torch.special.zeta(2, torch.tensor([1., 2.]))
tensor([1.6449, 0.6449])

文件

訪問 PyTorch 的完整開發者文件

查看文件

教學課程

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

查看教學課程

資源

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

查看資源