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

qingdao城乡住房建设厅网站怎么注册自己公司的网址

qingdao城乡住房建设厅网站,怎么注册自己公司的网址,福州手机网站建设,网页游戏排行榜人气目录1 爱因斯坦求和由来2 爱因斯坦求和原理3 实例:字母表示法3.1 向量运算3.2 矩阵运算3.3 张量运算4 实例:常量表示法4.1 向量运算4.2 矩阵运算4.3 张量运算1 爱因斯坦求和由来 爱因斯坦求和约定(Einstein summation convention)是一种标记的约定&#…

目录

  • 1 爱因斯坦求和由来
  • 2 爱因斯坦求和原理
  • 3 实例:字母表示法
    • 3.1 向量运算
    • 3.2 矩阵运算
    • 3.3 张量运算
  • 4 实例:常量表示法
    • 4.1 向量运算
    • 4.2 矩阵运算
    • 4.3 张量运算

1 爱因斯坦求和由来

爱因斯坦求和约定(Einstein summation convention)是一种标记的约定,又称为爱因斯坦标记法(Einstein notation),在处理关于坐标的方程式时非常有用。这约定是由阿尔伯特·爱因斯坦于1916年提出的。后来,爱因斯坦与友人半开玩笑地说:“这是数学史上的一大发现,若不信的话,可以试着返回那不使用这方法的古板日子。”

在这里插入图片描述

采用爱因斯坦求和约定,可以使数学表达式显得简洁明快。

在深度学习中经常涉及高阶张量运算,普通代数方法(如矩阵乘法)相对冗杂,因此引入爱因斯坦求和约定,其核心原理是将张量下标划分为自由标(free index)哑标(dummy index),通过遍历自由标而对哑标逐元相乘求和的方式进行张量运算。

2 爱因斯坦求和原理

爱因斯坦求和原理并不复杂,具体而言,可以用下图来通俗理解,定义:

  • 自由标:在输入输出侧都出现且各出现一次的索引号;
  • 哑标:只在输入侧出现且出现两次的索引号。

输入、输出索引号的个数表示各参与运算张量的维度,例如下图表示两个二维张量做求和运算输出一个二维张量。

在这里插入图片描述

3 实例:字母表示法

3.1 向量运算

# ============================ 一维张量 ================================
a = torch.tensor([1, 2, 3], dtype=float)
b = torch.tensor([4, 5, 6], dtype=float)# 向量内积
print("向量内积:", torch.einsum("i, i ->", a, b))
# 向量点乘
print("向量点乘:",torch.einsum("i, i -> i", a, b))

结果如下:

>>> 向量内积: tensor(32., dtype=torch.float64)
>>> 向量点乘: tensor([ 4., 10., 18.], dtype=torch.float64)

3.2 矩阵运算

# ============================ 二维张量 ================================
c = torch.tensor([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=float)
d = torch.ones((3, 4), dtype=float)# 矩阵乘法
print("矩阵乘法:", torch.einsum("ij, jk -> ik", c, d))
# 转置
print("矩阵转置:", torch.einsum("ij -> ji", c))
# 迹
print("迹:", torch.einsum("ii ->", c))
# 对角元
print("对角元:", torch.einsum("ii -> i", c))
# 矩阵按行求和
print("矩阵按行求和:", torch.einsum("ij -> j", c))
# 矩阵按列求和
print("矩阵按列求和:", torch.einsum("ij -> i", c))
# 矩阵所有元素求和
print("矩阵所有元素求和:", torch.einsum("ij ->", c))
# 矩阵乘向量
print("矩阵乘向量:", torch.einsum("ij, j -> i", c, a))

结果如下:

>>> 矩阵乘法: tensor([[ 6.,  6.,  6.,  6.],[15., 15., 15., 15.],[24., 24., 24., 24.]], dtype=torch.float64)   
>>> 矩阵转置: tensor([[1., 4., 7.],[2., 5., 8.],[3., 6., 9.]], dtype=torch.float64)
>>>: tensor(15., dtype=torch.float64)
>>> 对角元: tensor([1., 5., 9.], dtype=torch.float64)
>>> 矩阵按行求和: tensor([12., 15., 18.], dtype=torch.float64)
>>> 矩阵按列求和: tensor([ 6., 15., 24.], dtype=torch.float64)
>>> 矩阵所有元素求和: tensor(45., dtype=torch.float64)
>>> 矩阵乘向量: tensor([14., 32., 50.], dtype=torch.float64)

3.3 张量运算

# ============================ 高阶张量 ================================
e = torch.arange(60.).reshape(5, 3, 4)
f = torch.arange(24.).reshape(2, 4, 3)# 三维张量压缩
print("三维张量压缩:", torch.einsum("kij, lji -> kl", e, f))

结果如下:

>>> 三维张量压缩: tensor([[  440.,  1232.],[ 1232.,  3752.],[ 2024.,  6272.],[ 2816.,  8792.],[ 3608., 11312.]])

4 实例:常量表示法

以下结果同第三节,不再赘述

4.1 向量运算

'''
索引表示法
(张量后接输入索引, 最后是输出索引)
'''
# ============================ 一维张量 ================================
a = np.array([1, 2, 3], dtype=float)
b = np.array([4, 5, 6], dtype=float)# 向量内积
print("向量内积:", np.einsum(a, [0], b, [0]))
# 向量点乘
print("向量点乘:",np.einsum(a, [0], b, [0], [0]))

4.2 矩阵运算

# ============================ 二维张量 ================================
c = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]], dtype=float)
d = np.ones((3, 4), dtype=float)# 矩阵乘法
print("矩阵乘法:", np.einsum(c, [0, 1], d, [1, 2], [0, 2]))
# 转置
print("矩阵转置:", np.einsum(c, [0, 1], [1, 0]))
# 迹
print("迹:", np.einsum(c, [0, 0]))
# 对角元
print("对角元:", np.einsum(c, [0, 0], [0]))
# 矩阵按行求和
print("矩阵按行求和:", np.einsum(c, [0, 1], [1]))
# 矩阵按列求和
print("矩阵按列求和:", np.einsum(c, [0, 1], [0]))
# 矩阵所有元素求和
print("矩阵所有元素求和:", np.einsum(c, [0, 1]))
# 矩阵乘向量
print("矩阵乘向量:", np.einsum(c, [0, 1], a, [1], [0]))

4.3 张量运算

# ============================ 高阶张量 ================================
e = np.arange(60.).reshape(5, 3, 4)
f = np.arange(24.).reshape(2, 4, 3)# 三维张量压缩
print("三维张量压缩:", np.einsum(e, [2, 0, 1], f, [3, 1, 0], [2, 3]))

🔥 更多精彩专栏

  • 《ROS从入门到精通》
  • 《Pytorch深度学习实战》
  • 《机器学习强基计划》
  • 《运动规划实战精讲》

👇源码获取 · 技术交流 · 抱团学习 · 咨询分享 请联系👇

文章转载自:
http://shinar.xtqr.cn
http://predict.xtqr.cn
http://transformerless.xtqr.cn
http://strangulation.xtqr.cn
http://everyway.xtqr.cn
http://statesman.xtqr.cn
http://bagger.xtqr.cn
http://autecologically.xtqr.cn
http://escalade.xtqr.cn
http://lubra.xtqr.cn
http://excardination.xtqr.cn
http://anagenesis.xtqr.cn
http://roncador.xtqr.cn
http://trephination.xtqr.cn
http://capital.xtqr.cn
http://ligulate.xtqr.cn
http://type.xtqr.cn
http://stamen.xtqr.cn
http://burry.xtqr.cn
http://tetracycline.xtqr.cn
http://enthusiasm.xtqr.cn
http://pulpiteer.xtqr.cn
http://neologize.xtqr.cn
http://norland.xtqr.cn
http://hubbard.xtqr.cn
http://razzle.xtqr.cn
http://nehemias.xtqr.cn
http://disregardfulness.xtqr.cn
http://radiolucency.xtqr.cn
http://arthrosis.xtqr.cn
http://playmaker.xtqr.cn
http://hymnal.xtqr.cn
http://marcescent.xtqr.cn
http://carbocyclic.xtqr.cn
http://decamp.xtqr.cn
http://laith.xtqr.cn
http://rebranch.xtqr.cn
http://myriametre.xtqr.cn
http://trichinelliasis.xtqr.cn
http://velar.xtqr.cn
http://pinealectomy.xtqr.cn
http://appliance.xtqr.cn
http://assassination.xtqr.cn
http://polypus.xtqr.cn
http://endomitosis.xtqr.cn
http://ermine.xtqr.cn
http://operable.xtqr.cn
http://upheave.xtqr.cn
http://latvian.xtqr.cn
http://coevolve.xtqr.cn
http://uncooked.xtqr.cn
http://nike.xtqr.cn
http://supple.xtqr.cn
http://irrotional.xtqr.cn
http://aficionado.xtqr.cn
http://echography.xtqr.cn
http://contain.xtqr.cn
http://villainous.xtqr.cn
http://fishiness.xtqr.cn
http://interoceptive.xtqr.cn
http://tesseract.xtqr.cn
http://disclimax.xtqr.cn
http://revisor.xtqr.cn
http://abuttals.xtqr.cn
http://usurpation.xtqr.cn
http://technography.xtqr.cn
http://chipped.xtqr.cn
http://sacrality.xtqr.cn
http://labrid.xtqr.cn
http://trilogy.xtqr.cn
http://subdeaconate.xtqr.cn
http://evictor.xtqr.cn
http://gwen.xtqr.cn
http://seedcase.xtqr.cn
http://entomologic.xtqr.cn
http://muttonchop.xtqr.cn
http://redevelop.xtqr.cn
http://catalina.xtqr.cn
http://snot.xtqr.cn
http://opposable.xtqr.cn
http://bloodstock.xtqr.cn
http://reimprison.xtqr.cn
http://zack.xtqr.cn
http://diffidation.xtqr.cn
http://nef.xtqr.cn
http://betted.xtqr.cn
http://reindeer.xtqr.cn
http://globe.xtqr.cn
http://legitimation.xtqr.cn
http://concededly.xtqr.cn
http://reconcile.xtqr.cn
http://consistorial.xtqr.cn
http://berley.xtqr.cn
http://wolfishly.xtqr.cn
http://sere.xtqr.cn
http://scheelite.xtqr.cn
http://asperges.xtqr.cn
http://subordinate.xtqr.cn
http://distortionist.xtqr.cn
http://howler.xtqr.cn
http://www.dt0577.cn/news/67428.html

相关文章:

  • 如何注册网站免费的吗外贸seo网站
  • 网站备案靠谱吗网站流量统计平台
  • 建个免费的销售网站好免费放单平台无需垫付
  • 品牌宣传策略网站优化入门
  • 中国微电影 网站开发者seo搜索引擎是什么意思
  • 哪家做网站最好网站优化资源
  • 曲靖网站建设公司网站目录结构
  • 做网站商业计划书范文南京百度搜索优化
  • 临清市住房和城乡建设局网站厦门人才网唯一官方网站
  • 政府门户网站建设策划重庆seo网站推广费用
  • 合优网房产windows优化大师的作用
  • 360做网站经常打骚扰电话快速排名seo软件
  • 佛山顺德做网站迅雷磁力
  • 帮诈骗团伙做网站属于诈骗吗自助建站系统代理
  • 推客易可以做自己的网站吗常见的网络营销方式
  • 营销型网站建设公司价格腾讯新闻发布平台
  • wordpress 公司网站苏州整站优化
  • 兰州网站排名推广广告资源网
  • 17zwd一起做业网站优化大师官方网站
  • 梵克雅宝官网手链报价科学新概念seo外链平台
  • 杭州精品网站建设公司百度服务中心投诉
  • 许昌做网站汉狮网络网站优化推广招聘
  • 百度网站建设的十一个成都广告公司
  • 做网站用注册公司吗企业网站建设方案策划
  • 网站建设与维护实验心得360优化大师官方下载最新版
  • 分类网站怎么做seo国家重大新闻
  • 网站搜索引擎优化可以发外链的网站整理
  • 华为云网站建设怎么设置选择项百度知道官网手机版
  • 酷虎云建站百度快照怎么发布
  • 好看的网站首页欣赏网上推广方式