快捷方式

torch.sqrt

torch.sqrt(input, *, out=None) Tensor

返回一個新張量,其中包含 input 中元素的平方根。

outi=inputi\text{out}_{i} = \sqrt{\text{input}_{i}}
引數

input (Tensor) – 輸入張量。

關鍵字引數

out (Tensor, 可選) – 輸出張量。

示例

>>> a = torch.randn(4)
>>> a
tensor([-2.0755,  1.0226,  0.0831,  0.4806])
>>> torch.sqrt(a)
tensor([    nan,  1.0112,  0.2883,  0.6933])

文件

訪問 PyTorch 的完整開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源