torch.cos¶ torch.cos(input, *, out=None) → Tensor¶ 傳回一個新的 tensor,其中包含 input 元素的餘弦值。 outi=cos(inputi)\text{out}_{i} = \cos(\text{input}_{i}) outi=cos(inputi) 參數 input (Tensor) – 輸入張量。 關鍵字參數 out (Tensor, optional) – 輸出張量 (可選)。 範例 >>> a = torch.randn(4) >>> a tensor([ 1.4309, 1.2706, -0.8562, 0.9796]) >>> torch.cos(a) tensor([ 0.1395, 0.2957, 0.6553, 0.5574])