首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往
您找到你想要的搜索结果了吗?
是的
没有找到

torch.randn()、torch.mean()、torch.pow()、torch.matmul()

torch.randn()产生大小为指定的,正态分布的采样点,数据类型是tensortorch.mean()torch.mean(input) 输出input 各个元素的的均值,不指定任何参数就是所有元素的算术平均值...,指定参数可以计算每一行或者 每一列的算术平均数例如:a=torch.randn(3) #生成一个一维的矩阵b=torch.randn(1,3) #生成一个二维的矩阵print(a)print(b)torch.mean...(4,4)print(a)c=torch.mean(a,dim=0,keepdim=True)print(c)d=torch.mean(a,dim=1,keepdim=True)print(d)结果:tensor...torch.pow()对输入的每分量求幂次运算a=torch.tensor(3)b=torch.pow(a,2)print(b)c=torch.randn(4)print(c)d=torch.pow(c...()torch.matmul 是做矩阵乘法例如:a=torch.tensor([1,2,3])b=torch.tensor([3,4,5])torch.matmul(a, b)结果:tensor(26)

1.2K10

py

13020
领券