Python API
cos
逐元素计算余弦函数。
x – 输入张量。
计算得到的张量。
例如:
import numpy as np from megengine import tensor import megengine.functional as F x = tensor(np.arange(0, 6, dtype=np.float32).reshape(2, 3)) out = F.cos(x) print(out.numpy().round(decimals=4))
输出:
[[ 1. 0.5403 -0.4161] [-0.99 -0.6536 0.2837]]