-
加减乘除
torch.add(input, alpha=1, other, out=None)
torch.addcdiv(tensor, value=1, tensor1, tensor2, out=None)
torch.addcmul(tensor, value=1, tensor1, tensor2, out=None)
torch.sub(input, other, out=None)
torch.mul(input, other, out=None)
torch.div(input, other, out=None) -
对数,指数,幂函数
torch.log(input, out=None) ——以e为底
torch.log10(input, out=None)
torch.log2(input, out=None)
torch.exp(input, out=None)
torch.pow(input, exponent, out=None) -
三角函数
torch.acos(input, out=None)
torch.cosh(input, out=None)
torch.cos(input, out=None)
torch.asin(input, out=None)
torch.sinh(input, out=None)
torch.sin(input, out=None)
torch.atan(input, out=None)
torch.tanh(input, out=None)
torch.tan(input, out=None)
torch.atan2(input, other, out=None) -
绝对值
torch.abs(input, out=None)
torch.add()
torch.add(input,
alpha=1,
other,
out=None)
功能: 逐元素计算 input+alpha×other,因为深度学习中经常用到先乘后加的操作,所以增加了此功能,可以使代码更加整洁
- input: 第一个张量
- alpha: 乘项因子
- other: 第二个张量
torch.addcdiv()
torch.addcdiv(tensor,
value=1,
tensor1,
tensor2,
out=None)
功能: 逐元素计算 out=input+value×tensor1tensor2out = input + value \times \frac{tensor1}{tensor2}out=input+value×tensor2tensor1,优化过程中常用
torch.addcmul()
torch.addcmul(tensor,
value=1,
tensor1,
tensor2,
out=None)
功能: 逐元素计算 out=input+value×tensor1×tensor2out = input + value \times tensor1 \times tensor2out=input+value×tensor1×tensor2,优化过程中常用
torch.atan2()
torch.atan2(input,
other,
out=None)
功能: Element-wise arctangent of inputiotheri\frac{input_i}{other_i}otheriinputi with consideration of the quadrant. Returns a new tensor with the signed angles in radians between vector (otheri,inputiother_i, input_iotheri,inputi) and vector (1, 0).
注意: otheriother_iotheri, the second parameter, is the x-coordinate, while inputiinput_iinputi, the first parameter, is the y-coordinate.
本文详细介绍了PyTorch中的各种数学运算,包括加减乘除、对数、指数、幂函数、三角函数、绝对值等,以及这些运算在深度学习中的应用。特别关注了逐元素运算和特殊函数如atan2的使用。

345

被折叠的 条评论
为什么被折叠?



