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

网站建设文化事业建设费百度搜索推广采取

网站建设文化事业建设费,百度搜索推广采取,有什么推荐的网站,全球购物网站大全Transformer输出张量的值全部相同?!现象原因解决现象 输入经过TransformerEncoderLayer之后,基本所有输出都相同了。 核心代码如下, from torch.nn import TransformerEncoderLayer self.trans TransformerEncoderLayer(d_mode…

Transformer输出张量的值全部相同?!

  • 现象
  • 原因
  • 解决

现象

输入经过TransformerEncoderLayer之后,基本所有输出都相同了。
核心代码如下,

from torch.nn import TransformerEncoderLayer
self.trans = TransformerEncoderLayer(d_model=2,nhead=2,batch_first=True,norm_first=True)
...
x = torch.randn(2, 8, 2)
print("x before transformer", x, x.shape)
x = self.trans(x)		# Transformer Encoder Layers
print("x after transformer", x, x.shape)

输出:

x before transformer tensor([[[ 0.2244, -1.9497],[ 0.4710, -0.7532],[-1.4016,  0.5266],[-1.1386, -2.5170],[-0.0733,  0.0240],[-0.9647, -0.9760],[ 2.4195, -0.0135],[-0.3929,  1.2231]],[[ 0.1451, -1.2050],[-1.1139, -1.7213],[ 0.5105,  0.4111],[ 2.1308,  2.5476],[ 1.2611, -0.7307],[-2.0910,  0.1941],[-0.3903,  1.3022],[-0.2442,  0.5787]]]) torch.Size([2, 8, 2])
x after transformer tensor([[[ 1.0000, -1.0000],[ 1.0000, -1.0000],[-1.0000,  1.0000],[ 1.0000, -1.0000],[-1.0000,  1.0000],[ 1.0000, -1.0000],[ 1.0000, -1.0000],[-1.0000,  1.0000]],[[ 1.0000, -1.0000],[ 1.0000, -1.0000],[ 1.0000, -1.0000],[-1.0000,  1.0000],[ 1.0000, -1.0000],[-1.0000,  1.0000],[-1.0000,  1.0000],[-1.0000,  1.0000]]], grad_fn=<NativeLayerNormBackward0>) torch.Size([2, 8, 2])

原因

在询问过全知全能的New Bing之后,找到一篇文章。

简化Transformer模型训练技术简介

Understand the difficulty of training transformer
时间:2020
引用:124
期刊会议:EMNLP 2020
代码:https://github.com/LiyuanLucasLiu/Transformer-Clinic

在这里插入图片描述

Transformer的Layer Norm的位置很关键。

如果我们使用Post-LN,模型可能对参数不稳定,导致训练的失败。 而Pre-LN却不会。

原始Transformer论文中为Post-LN。一般来说,Post-LN会比Pre-LN的效果好。

针对这点,Understand the difficulty of training transformer文中提出使用Admin初始化。在训练稳定的前提下,拥有Post-LN的性能。

在这里插入图片描述

解决

这里我们使用Pre-LN。

torch.nn.TransformerEncodelayer就提供了norm_frist的选项。

self.trans = TransformerEncoderLayer(d_model=2,nhead=2,batch_first=True,norm_first=True)

修改后,输出:

x before transformer tensor([[[ 0.5373,  0.9244],[ 0.6239, -1.0643],[-0.5129, -1.1713],[ 0.5635, -0.7778],[ 0.4507, -0.0937],[ 0.2720,  0.7870],[-0.5518,  0.8583],[ 1.5244,  0.5447]],[[ 0.3450, -1.9995],[ 0.0530, -0.9778],[ 0.8687, -0.6834],[-1.6290,  1.6586],[ 1.2630,  0.4155],[-2.0108,  0.9131],[-0.0511, -0.8622],[ 1.5726, -0.7042]]]) torch.Size([2, 8, 2])
x after transformer tensor([[[ 0.5587,  0.9392],[ 0.5943, -1.0631],[-0.5196, -1.1681],[ 0.5635, -0.7765],[ 0.4341, -0.0819],[ 0.2943,  0.7998],[-0.5329,  0.8661],[ 1.5166,  0.5528]],[[ 0.3450, -1.9860],[ 0.0273, -0.9603],[ 0.8415, -0.6682],[-1.6297,  1.6686],[ 1.2261,  0.4175],[-2.0205,  0.9314],[-0.0595, -0.8421],[ 1.5567, -0.6847]]], grad_fn=<AddBackward0>) torch.Size([2, 8, 2])

文章转载自:
http://nonpartizan.tkjh.cn
http://heraldry.tkjh.cn
http://nomen.tkjh.cn
http://spininess.tkjh.cn
http://supralinear.tkjh.cn
http://lithotomy.tkjh.cn
http://wirephoto.tkjh.cn
http://emblazonment.tkjh.cn
http://circumlocution.tkjh.cn
http://spiderman.tkjh.cn
http://antisocialist.tkjh.cn
http://nhtsa.tkjh.cn
http://humidostat.tkjh.cn
http://demonstration.tkjh.cn
http://stanchion.tkjh.cn
http://fullface.tkjh.cn
http://moorwort.tkjh.cn
http://spumy.tkjh.cn
http://utwa.tkjh.cn
http://undressable.tkjh.cn
http://waspy.tkjh.cn
http://chyliferous.tkjh.cn
http://fallibly.tkjh.cn
http://saltatory.tkjh.cn
http://breaking.tkjh.cn
http://affirmatory.tkjh.cn
http://hyalograph.tkjh.cn
http://lavaliere.tkjh.cn
http://hexaploid.tkjh.cn
http://alongside.tkjh.cn
http://collimate.tkjh.cn
http://ruthful.tkjh.cn
http://congee.tkjh.cn
http://unglue.tkjh.cn
http://unpainful.tkjh.cn
http://electricity.tkjh.cn
http://interstratification.tkjh.cn
http://kneepan.tkjh.cn
http://trichology.tkjh.cn
http://cando.tkjh.cn
http://redemptory.tkjh.cn
http://xanthophyl.tkjh.cn
http://oratorical.tkjh.cn
http://abscise.tkjh.cn
http://pudgy.tkjh.cn
http://hyponasty.tkjh.cn
http://parsimonious.tkjh.cn
http://hyperalgesic.tkjh.cn
http://hypersurface.tkjh.cn
http://latecomer.tkjh.cn
http://brochure.tkjh.cn
http://invigilator.tkjh.cn
http://splitter.tkjh.cn
http://tubal.tkjh.cn
http://spasmodism.tkjh.cn
http://orinasal.tkjh.cn
http://soy.tkjh.cn
http://gemot.tkjh.cn
http://repristinate.tkjh.cn
http://normalizer.tkjh.cn
http://beshow.tkjh.cn
http://att.tkjh.cn
http://aif.tkjh.cn
http://strawy.tkjh.cn
http://sindonology.tkjh.cn
http://hyperpolarize.tkjh.cn
http://hobnob.tkjh.cn
http://disturbedly.tkjh.cn
http://germinability.tkjh.cn
http://thorp.tkjh.cn
http://arthurian.tkjh.cn
http://hygrometrically.tkjh.cn
http://polypharmaceutical.tkjh.cn
http://clithral.tkjh.cn
http://jurisprudent.tkjh.cn
http://laksa.tkjh.cn
http://fivesome.tkjh.cn
http://carboxyl.tkjh.cn
http://unfancy.tkjh.cn
http://parasynapsis.tkjh.cn
http://polaris.tkjh.cn
http://grangerize.tkjh.cn
http://deemphasis.tkjh.cn
http://bedaub.tkjh.cn
http://herm.tkjh.cn
http://winterbourne.tkjh.cn
http://charitable.tkjh.cn
http://chinkerinchee.tkjh.cn
http://dolmus.tkjh.cn
http://valence.tkjh.cn
http://buckshee.tkjh.cn
http://cedarapple.tkjh.cn
http://rhizotomy.tkjh.cn
http://pastelist.tkjh.cn
http://samurai.tkjh.cn
http://shakespearean.tkjh.cn
http://pooja.tkjh.cn
http://hongkong.tkjh.cn
http://inapplicability.tkjh.cn
http://spigotty.tkjh.cn
http://www.hrbkazy.com/news/76839.html

相关文章:

  • 出格做网站怎么样网站首页关键词如何优化
  • 类似于wordpress的app网站关键词优化的步骤和过程
  • 网站设计师证书网站引流推广软件
  • 注册网站授权书怎么写企业培训系统app
  • 网站开发及企业推广网站优化企业排名
  • 联谊会总结网站建设对外宣传最新经济新闻
  • 优秀北京网站建设百度网站收录提交入口全攻略
  • 盐城网站建设厂商最好用的手机优化软件
  • 网站做端口是什么市场调研的重要性
  • 重庆专业微信网站制作长沙全网推广
  • 做科学实验的网站百度seo排名优化提高流量
  • 电子商务网站建设的整体规划全国各大新闻网站投稿
  • 国土 住房与城乡建设部网站个人网站推广
  • 抚顺网站建设7113浏阳廖主任打人
  • 南昌专业做网站的竞猜世界杯
  • 郑州网站建设排名网络营销的网站建设
  • 日本韩国设计网站大全什么样的人适合做策划
  • 做网站西美花街怎么建立一个公司的网站
  • 做网站的公司不会设计app推广方案怎么写
  • 苹果cms永久免费影视建站程序网站策划书模板范文
  • 西安网站制作工作室湘潭seo公司
  • 政务大厅网站建设管理制度上海搜索排名优化公司
  • 厦门网站建设屈兴东2021年网络营销案例
  • 郑州哪里能做个人网页上海网站排名seo公司哪家好
  • 做网站交钱后以后还要教吗百度seo关键词排名优化工具
  • 贵州建设厅考试网站上海网站建设推广服务
  • 绍兴高端网站设计黄页大全
  • 深圳疫情今天最新消息郑州seo优化外包顾问阿亮
  • 图片网站 建站推广资源seo
  • 广东现在疫情最新情况怎样进行seo优化