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

建设网站与服务器手机版网页

建设网站与服务器,手机版网页,个人介绍网页模板免费下载,手机网站怎么导入微信0. Intro 以pytorch为例#xff0c;BatchNorm1d的参数num_features涉及了对什么数据进行处理#xff0c;但是我总是记不住#xff0c;写个blog帮助自己理解QAQ 1. 复现nn.BatchNorm1d(num_features1) 假设有一个input tensor#xff1a; input torch.tensor([[[1.,2.,…0. Intro 以pytorch为例BatchNorm1d的参数num_features涉及了对什么数据进行处理但是我总是记不住写个blog帮助自己理解QAQ 1. 复现nn.BatchNorm1d(num_features1) 假设有一个input tensor input torch.tensor([[[1.,2.,3.,4.]],[[0.,0.,0.,0.]]]) print(input.shape) # torch.Size([2, 1, 4])nn.BatchNorm1d(num_features1)函数介绍 这个函数长这个样子 torch.nn.BatchNorm1d(num_features, eps1e-05, momentum0.1, affineTrue, track_running_statsTrue, deviceNone, dtypeNone)使用起来是这样的: BN1 nn.BatchNorm1d(num_features1,affineFalse,eps0) # input只有1个feature只有1个channel每个features的长度4第一个batch print(---BN1---) print(torch.squeeze(BN1(input)))注意1函数参数eps0是为了让下图这个batchnorm的公式的这个等于0起保护作用eps默认为1e-5 注意2上式里的γ\gammaγ和β\betaβ分别默认值是1和0因此只要设置affineFalse就可以使用了注意affine默认为Trueinput shape符合BatchNorm1d要求的[B,C,L]的格式这里num_features1与C对应 上面函数的输出为 ---BN1--- tensor([[-0.1690, 0.5071, 1.1832, 1.8593],[-0.8452, -0.8452, -0.8452, -0.8452]])nn.BatchNorm1d(num_features1)复现结果 ans (input-torch.mean(torch.flatten(input)))/torch.sqrt(torch.var(torch.flatten(input),unbiasedFalse)) print(torch.squeeze(ans))注意1torch.flatten()很重要它刚好体现了BN层做norm时会把每个feature在不同batch中的值拉平然后做norm不管是矩阵还是序列注意2torch.var的参数unbiasedFalse表示求方差时分母是n也就是不需要求无偏的方差 它的输出为 tensor([[-0.1690, 0.5071, 1.1832, 1.8593],[-0.8452, -0.8452, -0.8452, -0.8452]])一模一样 2. 复现nn.BatchNorm1d(num_features4) 依然假设有一个input tensor和上面一样复制过来 input torch.tensor([[[1.,2.,3.,4.]],[[0.,0.,0.,0.]]]) print(input.shape) # torch.Size([2, 1, 4])nn.BatchNorm1d(num_features4) 函数介绍 首先这个函数使用起来是这样的 BN2 nn.BatchNorm1d(num_features4,affineFalse,eps0) print(---BN2---) print(BN2(torch.squeeze(input)))注意点1torch.squeeze是必须的使用之后tensor的shape会从torch.Size([2, 1, 4])变为torch.Size([2, 4])符合BatchNorm1d要求的[B,C]的格式这里num_features4与C对应上面的函数输出为 ---BN2--- tensor([[ 1., 1., 1., 1.],[-1., -1., -1., -1.]])复现 重点来了我们理解一下num_features4对于现在的input data经过squeeze之后shape为[B,C] [2,4]input data的每个feature现在是一个single value值不是序列或者矩阵因此这里可以对某个feature手动计算一下 以最后一个feature为例[4,0],可以计算得mean2sqrt(var)2因此([4,0]-mean)/sqrt(var)[1,-1]同理可以计算其他3个feature 一模一样 上面的代码 input torch.tensor([[[1.,2.,3.,4.]],[[0.,0.,0.,0.]]]) print(input.shape)BN1 nn.BatchNorm1d(num_features1,affineFalse,eps0) # 每个features的长度4第一个batch print(---BN1---) print(torch.squeeze(BN1(input))) print(---BN1 Repeat---) ans (input-torch.mean(torch.flatten(input)))/torch.sqrt(torch.var(torch.flatten(input),unbiasedFalse) ) print(torch.squeeze(ans))BN2 nn.BatchNorm1d(num_features4,affineFalse,eps0) print(---BN2---) print(BN2(torch.squeeze(input))) # BN2就手动算一下啦3. 对于BatchNorm2d是类似的 注意点其实只有2点 找准feature是什么BN层做norm时会把每个feature在不同batch中的值拉平然后做norm不管是矩阵还是序列
文章转载自:
http://www.morning.lysrt.cn.gov.cn.lysrt.cn
http://www.morning.gkmwx.cn.gov.cn.gkmwx.cn
http://www.morning.rnmc.cn.gov.cn.rnmc.cn
http://www.morning.nxdqz.cn.gov.cn.nxdqz.cn
http://www.morning.whothehellami.com.gov.cn.whothehellami.com
http://www.morning.pltbd.cn.gov.cn.pltbd.cn
http://www.morning.ywqw.cn.gov.cn.ywqw.cn
http://www.morning.kjsft.cn.gov.cn.kjsft.cn
http://www.morning.rmltt.cn.gov.cn.rmltt.cn
http://www.morning.rjtmg.cn.gov.cn.rjtmg.cn
http://www.morning.27asw.cn.gov.cn.27asw.cn
http://www.morning.zyffq.cn.gov.cn.zyffq.cn
http://www.morning.tclqf.cn.gov.cn.tclqf.cn
http://www.morning.wknjy.cn.gov.cn.wknjy.cn
http://www.morning.znsyn.cn.gov.cn.znsyn.cn
http://www.morning.bktly.cn.gov.cn.bktly.cn
http://www.morning.qwmpn.cn.gov.cn.qwmpn.cn
http://www.morning.sbjbs.cn.gov.cn.sbjbs.cn
http://www.morning.lzqdd.cn.gov.cn.lzqdd.cn
http://www.morning.rpljf.cn.gov.cn.rpljf.cn
http://www.morning.mhmcr.cn.gov.cn.mhmcr.cn
http://www.morning.jppb.cn.gov.cn.jppb.cn
http://www.morning.bqwrn.cn.gov.cn.bqwrn.cn
http://www.morning.zbnkt.cn.gov.cn.zbnkt.cn
http://www.morning.rlbfp.cn.gov.cn.rlbfp.cn
http://www.morning.c7617.cn.gov.cn.c7617.cn
http://www.morning.gpsr.cn.gov.cn.gpsr.cn
http://www.morning.tbwsl.cn.gov.cn.tbwsl.cn
http://www.morning.xpmwt.cn.gov.cn.xpmwt.cn
http://www.morning.jllnh.cn.gov.cn.jllnh.cn
http://www.morning.hmsong.com.gov.cn.hmsong.com
http://www.morning.rmfw.cn.gov.cn.rmfw.cn
http://www.morning.gnwpg.cn.gov.cn.gnwpg.cn
http://www.morning.njftk.cn.gov.cn.njftk.cn
http://www.morning.bzlsf.cn.gov.cn.bzlsf.cn
http://www.morning.qjghx.cn.gov.cn.qjghx.cn
http://www.morning.klzt.cn.gov.cn.klzt.cn
http://www.morning.lwyqd.cn.gov.cn.lwyqd.cn
http://www.morning.yxnkr.cn.gov.cn.yxnkr.cn
http://www.morning.nmbbt.cn.gov.cn.nmbbt.cn
http://www.morning.jhswp.cn.gov.cn.jhswp.cn
http://www.morning.rgqnt.cn.gov.cn.rgqnt.cn
http://www.morning.drytb.cn.gov.cn.drytb.cn
http://www.morning.wpwyx.cn.gov.cn.wpwyx.cn
http://www.morning.pltbd.cn.gov.cn.pltbd.cn
http://www.morning.ndmh.cn.gov.cn.ndmh.cn
http://www.morning.lyrgp.cn.gov.cn.lyrgp.cn
http://www.morning.pfkrw.cn.gov.cn.pfkrw.cn
http://www.morning.ktqtf.cn.gov.cn.ktqtf.cn
http://www.morning.yqsq.cn.gov.cn.yqsq.cn
http://www.morning.zrrgx.cn.gov.cn.zrrgx.cn
http://www.morning.pjrql.cn.gov.cn.pjrql.cn
http://www.morning.rwjfs.cn.gov.cn.rwjfs.cn
http://www.morning.tbnn.cn.gov.cn.tbnn.cn
http://www.morning.lfxcj.cn.gov.cn.lfxcj.cn
http://www.morning.rjmg.cn.gov.cn.rjmg.cn
http://www.morning.trnl.cn.gov.cn.trnl.cn
http://www.morning.bhrkx.cn.gov.cn.bhrkx.cn
http://www.morning.ltbwq.cn.gov.cn.ltbwq.cn
http://www.morning.bangaw.cn.gov.cn.bangaw.cn
http://www.morning.fzlk.cn.gov.cn.fzlk.cn
http://www.morning.dpsyr.cn.gov.cn.dpsyr.cn
http://www.morning.dmwbs.cn.gov.cn.dmwbs.cn
http://www.morning.diuchai.com.gov.cn.diuchai.com
http://www.morning.wtbzt.cn.gov.cn.wtbzt.cn
http://www.morning.nrddx.com.gov.cn.nrddx.com
http://www.morning.dxsyp.cn.gov.cn.dxsyp.cn
http://www.morning.tmcmj.cn.gov.cn.tmcmj.cn
http://www.morning.hcrxn.cn.gov.cn.hcrxn.cn
http://www.morning.hjwzpt.com.gov.cn.hjwzpt.com
http://www.morning.jtqxs.cn.gov.cn.jtqxs.cn
http://www.morning.dqdss.cn.gov.cn.dqdss.cn
http://www.morning.mmqhq.cn.gov.cn.mmqhq.cn
http://www.morning.mszwg.cn.gov.cn.mszwg.cn
http://www.morning.rzczl.cn.gov.cn.rzczl.cn
http://www.morning.rbgwj.cn.gov.cn.rbgwj.cn
http://www.morning.sgjw.cn.gov.cn.sgjw.cn
http://www.morning.jnbsx.cn.gov.cn.jnbsx.cn
http://www.morning.lbcbq.cn.gov.cn.lbcbq.cn
http://www.morning.yhdqq.cn.gov.cn.yhdqq.cn
http://www.tj-hxxt.cn/news/266136.html

相关文章:

  • delphi网站开发网站赚钱
  • 手机网站分享代码网站推广业务
  • 辽宁建设信息网站手机网站 微信分享
  • 个人建站教程自己做优惠券网站
  • 建设网站的源代码的所有权网站建设我们的优势
  • 网站建设维护协议国外域名。国内网站
  • 创意设计网站做门户网站用什么系统
  • 网站建设后的优势网站如何制作学校的做
  • 做HH网站郑州电力高等专科学校招生网
  • 安徽住房和城乡建设部网站首页建设产品信息网站
  • 电商网站开发工作计划网站网站建设报价
  • wordpress建站插件做注册会员和购物的网站需要什么
  • 营销型网站建设要多少钱用vs做购物网站下载
  • 天津网站建设企业系统网站建设在马来西亚
  • 电商网站建设会计分录django做的网站源码
  • 网站优化需要做什么长沙公司网站设计报价
  • 如何将自己做的网站放到网上去制造企业网站建设
  • 广东省网站备案查询科技未来网站建设
  • 建设网站页面大气企业网站模板
  • 建筑行业招聘网站排行榜wordpress全图水印
  • 做网站关键词软件关键词seo技术
  • 用自己电脑建设网站电商网站开发总结与感受
  • 面料做电商 哪个网站好个人微企业网站模板
  • 域名注册完成后怎么做网站网络安装
  • 网站 服务器选择做网站建设的一般在哪儿找
  • 岳阳市城市建设投资公司网站网站的域名分为哪些
  • 淘宝网站小视频怎么做网站付费模板
  • 潼关县住房和城乡建设局网站wordpress的代码在哪里
  • .net 建网站上海网站建设解决方案
  • 云南省建设厅网站处长兰州网站制作公司在哪里