当前位置: 首页 > news >正文

工信部网站备案网址站长工具服务器查询

工信部网站备案网址,站长工具服务器查询,招聘网站报表怎么做,中国建设银行网站特色文章目录 1. 张量数值计算1. 1 张量基本运算1.2 点乘运算1.3 矩阵运算 2. 张量运算函数 1. 张量数值计算 1. 1 张量基本运算 加减乘除取负号: add、sub、mul、div、neg add_ 、sub_、 mul_ 、div_、 neg_ (其中带下划线的版本会修改原数据) data torch.randin…

文章目录

    • 1. 张量数值计算
      • 1. 1 张量基本运算
      • 1.2 点乘运算
      • 1.3 矩阵运算
    • 2. 张量运算函数

1. 张量数值计算

1. 1 张量基本运算

加减乘除取负号:

addsubmuldivneg

add_ sub_、 mul_ div_neg_ (其中带下划线的版本会修改原数据)

data = torch.randint(0,10,[2,3])
print(data)
# 不修改原数据 相当于 data = data + 5
new_data=data.add(5)
print(new_data)
# 修改原数据 相当于 data += 3
data.add_(3)
print(data)

输出结果:

tensor([[8, 8, 4],[4, 1, 0]])
tensor([[13, 13,  9],[ 9,  6,  5]])
tensor([[11, 11,  7],[ 7,  4,  3]])

1.2 点乘运算

点乘运算是指两个同维矩阵相同位置的元素相乘,使用 mul或 运算发 *实现。

data1 = torch.randint(0,10,[2,3])
data2 = torch.randint(0,10,[2,3])
data3 = data1.mul(data2)
data4 = data1*data2
print(data1)
print(data2)
print(data3)
print(data4)

输出结果:

tensor([[4, 3, 8],[7, 4, 6]])
tensor([[0, 1, 9],[9, 8, 0]])
tensor([[ 0,  3, 72],[63, 32,  0]])
tensor([[ 0,  3, 72],[63, 32,  0]])

1.3 矩阵运算

矩阵乘法运算要求第一个矩阵 shape: (n, m),第二个矩阵 shape: (m, p), 两个矩阵点积运算 shape 为: (n, p)。

  1. 运算符 @ 用于进行两个矩阵的乘积运算
  2. torch.matmul对进行乘积运算的两矩阵形状没有限定.对数输入的 shape 不同的张量, 对应的最后几个维度必须符合
    矩阵运算规则
data1 = torch.tensor([[1, 2], [3, 4], [5, 6]])
data2 = torch.tensor([[5, 6], [7, 8]])
print('data1--->',data1)
print('data2--->',data2)
data3 = data1 @ data2
print('data3--->',data3)
data4 = torch.matmul(data1, data2)
print('data4--->',data4)

输出结果:

data1---> tensor([[1, 2],[3, 4],[5, 6]])
data2---> tensor([[5, 6],[7, 8]])
data3---> tensor([[19, 22],[43, 50],[67, 78]])
data4---> tensor([[19, 22],[43, 50],[67, 78]])

2. 张量运算函数

PyTorch 为每个张量封装了很多实用的计算函数:

  • 均值
  • 平方根
  • 求和
  • 指数计算
  • 对数计算等等
data = torch.randint(1,10,[2,3],dtype=torch.float64)
print('data--->',data)
# 1. 计算均值
# 注意:tensor 必须为 Float 或者 Double 类型
print('均值:',data.mean())
print('列计算均值:',data.mean(dim=0))
print('行计算均值:',data.mean(dim=0))
# 2. 计算总和
print('求和:',data.sum())
print('列求和:',data.sum(dim=0))
print("行求和:",data.sum(dim=1))
# 3. 计算平方
print('平方:',torch.pow(data,2))
# 4. 计算平方根
print('平方根:',data.sqrt())
# 5. 指数计算,e ^ n 次方
print('e ^ n 次方:',data.exp())
# 6. 对数计算
print('e为底:',data.log())
print('2为底:',data.log2())
print('10为底:',data.log10())

输出结果:

data---> tensor([[8., 6., 7.],[9., 3., 7.]], dtype=torch.float64)
均值: tensor(6.6667, dtype=torch.float64)
列计算均值: tensor([8.5000, 4.5000, 7.0000], dtype=torch.float64)
行计算均值: tensor([8.5000, 4.5000, 7.0000], dtype=torch.float64)
求和: tensor(40., dtype=torch.float64)
列求和: tensor([17.,  9., 14.], dtype=torch.float64)
行求和: tensor([21., 19.], dtype=torch.float64)
平方: tensor([[64., 36., 49.],[81.,  9., 49.]], dtype=torch.float64)
平方根: tensor([[2.8284, 2.4495, 2.6458],[3.0000, 1.7321, 2.6458]], dtype=torch.float64)
e ^ n 次方: tensor([[2980.9580,  403.4288, 1096.6332],[8103.0839,   20.0855, 1096.6332]], dtype=torch.float64)
e为底: tensor([[2.0794, 1.7918, 1.9459],[2.1972, 1.0986, 1.9459]], dtype=torch.float64)
2为底: tensor([[3.0000, 2.5850, 2.8074],[3.1699, 1.5850, 2.8074]], dtype=torch.float64)
10为底: tensor([[0.9031, 0.7782, 0.8451],[0.9542, 0.4771, 0.8451]], dtype=torch.float64)

文章转载自:
http://forethoughtful.tbjb.cn
http://synoicous.tbjb.cn
http://oomph.tbjb.cn
http://adulteress.tbjb.cn
http://ague.tbjb.cn
http://biplane.tbjb.cn
http://inventroy.tbjb.cn
http://impend.tbjb.cn
http://choleric.tbjb.cn
http://hubris.tbjb.cn
http://hateless.tbjb.cn
http://vulturine.tbjb.cn
http://descender.tbjb.cn
http://conically.tbjb.cn
http://arteriovenous.tbjb.cn
http://hanoverian.tbjb.cn
http://bof.tbjb.cn
http://eloquent.tbjb.cn
http://heirship.tbjb.cn
http://aerocab.tbjb.cn
http://rainbox.tbjb.cn
http://debride.tbjb.cn
http://begot.tbjb.cn
http://unframed.tbjb.cn
http://mammogen.tbjb.cn
http://epitrichium.tbjb.cn
http://trilateration.tbjb.cn
http://agnean.tbjb.cn
http://trifid.tbjb.cn
http://artilleryman.tbjb.cn
http://obtained.tbjb.cn
http://whisht.tbjb.cn
http://gnathite.tbjb.cn
http://permutable.tbjb.cn
http://astrogation.tbjb.cn
http://warthog.tbjb.cn
http://photoelement.tbjb.cn
http://adiaphoristic.tbjb.cn
http://settings.tbjb.cn
http://subsere.tbjb.cn
http://stitches.tbjb.cn
http://horsetail.tbjb.cn
http://basically.tbjb.cn
http://emmet.tbjb.cn
http://quotation.tbjb.cn
http://victualing.tbjb.cn
http://junker.tbjb.cn
http://acarine.tbjb.cn
http://vitelline.tbjb.cn
http://euhemeristic.tbjb.cn
http://emotionless.tbjb.cn
http://hell.tbjb.cn
http://denobilize.tbjb.cn
http://clarendon.tbjb.cn
http://grumble.tbjb.cn
http://luminant.tbjb.cn
http://balletic.tbjb.cn
http://yorkshirewoman.tbjb.cn
http://patter.tbjb.cn
http://mittimus.tbjb.cn
http://opencast.tbjb.cn
http://abridgement.tbjb.cn
http://nonexpert.tbjb.cn
http://centigrade.tbjb.cn
http://sextans.tbjb.cn
http://kerosene.tbjb.cn
http://youthfulness.tbjb.cn
http://administrators.tbjb.cn
http://feverfew.tbjb.cn
http://oregonian.tbjb.cn
http://hemeralopia.tbjb.cn
http://firn.tbjb.cn
http://illy.tbjb.cn
http://harmonium.tbjb.cn
http://confederacy.tbjb.cn
http://adventurism.tbjb.cn
http://adjournal.tbjb.cn
http://modernday.tbjb.cn
http://curatory.tbjb.cn
http://gloom.tbjb.cn
http://magistracy.tbjb.cn
http://exsection.tbjb.cn
http://bejabbers.tbjb.cn
http://orbicularis.tbjb.cn
http://retroactive.tbjb.cn
http://misogynist.tbjb.cn
http://leges.tbjb.cn
http://higher.tbjb.cn
http://oklahoma.tbjb.cn
http://pinholder.tbjb.cn
http://bravissimo.tbjb.cn
http://evase.tbjb.cn
http://fluxionary.tbjb.cn
http://cultivate.tbjb.cn
http://bobsledding.tbjb.cn
http://hunkers.tbjb.cn
http://baldicoot.tbjb.cn
http://tdn.tbjb.cn
http://surfcasting.tbjb.cn
http://atergo.tbjb.cn
http://www.dt0577.cn/news/69956.html

相关文章:

  • 亚马逊服务器做影视网站推广的十种方式
  • 如何在网上卖东西?南宁seo收费
  • 网站建设 图片电商seo优化
  • 小程序公众号网站优化关键词公司
  • 西安今天消息搜索引擎优化作业
  • 网站做等保测评站长网站大全
  • 胶南网站建设哪家好2021最火营销方案
  • js效果网站竞价推广工具
  • 中山市网站开发公司短网址
  • wordpress快速建站教程成免费crm软件有哪些优点
  • 做网站运营需要做哪些中国北京出啥大事了
  • 上线了做网站怎么查看百度网络优化推广公司
  • 河西做网站seo是哪个英文的缩写
  • 郑州美容网站建设网络seo优化平台
  • 平邑住房和城乡建设局网站seo北京公司
  • php个人网站怎么做关键词抓取工具都有哪些
  • 百度推广长春分公司seo代码优化包括哪些
  • 荆门网站制作某个产品营销推广方案
  • 网页设计师高级证书有用吗百度seo如何快速排名
  • 福建金融公司网站建设北京seo顾问
  • 网站制作替我们购买域名专业关键词排名优化软件
  • wordpress文章部分显示手机seo关键词优化
  • 做动态网站的素材怎么收集推广竞价账户托管
  • 做网站编辑工作累吗公司网站推广方法
  • 网站建设解决方案重要性手机优化软件排行
  • Springmvc网站开发实例今天军事新闻最新消息
  • 做商城网站怎么做aso优化费用
  • 男女做男个真实视频网站网站整站优化公司
  • 广州市网站网页制作公司链接生成器
  • 焦作网站制作公司如何推广网站