矩阵之间的 add/sub/mul/div/ 加减乘除 矩阵和标量
矩阵相乘
torch.mm() 只针对二维的矩阵
torch.matmul(a,b) / a@b
pytorch [channle out, channle in]
a.shape() = [4,784]
w.shape() = [512,784]
(a@w.t()).shape() = [4,512] w转置后相乘
a.shape() = [4,3,28,64]
b.shape() = [4,3,64,28]
torch.matmul(a,b).shape() = [4,3,28,28] 最后两维进行相乘
幂次方
pow(a,2/3/4)
sqrt() 平方 rsqrt() 平方倒数
torch.exp(torch.ones(2,2)) 以e为底的矩阵
torch.log()
近似
.floor() 向下走 .ceil() 向上走
.round() 四舍五入
.trunc() 取整数部分 .frac() 取小数部分
打印梯度的模 w.grad.norm(2)
a.clamp(min) 大于min给 min
a.clamp(min,max) 所有数在(min,max)之间