torch.square¶ torch.square(input: Tensor, *, out: Optional[Tensor]) → Tensor¶ 傳回一個新的 tensor,其元素為 input 中元素的平方。 參數 input (Tensor) – 輸入的 tensor。 關鍵字參數 out (Tensor, optional) – 輸出 tensor (可選)。 範例 >>> a = torch.randn(4) >>> a tensor([-2.0755, 1.0226, 0.0831, 0.4806]) >>> torch.square(a) tensor([ 4.3077, 1.0457, 0.0069, 0.2310])