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

女士手表网站优化公司组织架构

女士手表网站,优化公司组织架构,怎么做网站移植网站,几个小时学wordpress一 添加BN模块 BN模块应该添加 激活层前面 在模型实例化后,我们需要对BN层进行初始化。PyTorch中的BN层是通过nn.BatchNorm1d或nn.BatchNorm2d类来实现的。 bn nn.BatchNorm1d(20) # 对于1D输入数据,使用nn.BatchNorm1d;对于2D输入数据&am…

一 添加BN模块

BN模块应该添加 激活层前面

在模型实例化后,我们需要对BN层进行初始化。PyTorch中的BN层是通过nn.BatchNorm1d或nn.BatchNorm2d类来实现的。

bn = nn.BatchNorm1d(20) #
对于1D输入数据,使用nn.BatchNorm1d;对于2D输入数据,使用nn.BatchNorm2d

在模型的前向传播过程中,我们需要将BN层应用到适当的位置。以全连接层为例,我们需要在全连接层的输出之后调用BN层。

class MyModel(nn.Module):def __init__(self):super(MyModel, self).__init__()self.fc1 = nn.Linear(10, 20)self.bn = nn.BatchNorm1d(20)self.fc2 = nn.Linear(20, 30)self.fc3 = nn.Linear(30, 2)def forward(self, x):x = self.fc1(x)x = self.bn(x)x = self.fc2(x)x = self.fc3(x)return x

二 添加残差连接

最主要的是需要注意输入参数的维度是否一致

import torch
import torch.nn as nnclass ResidualBlock(nn.Module):def __init__(self, input_size, hidden_size):super(ResidualBlock, self).__init__()self.fc1 = nn.Linear(input_size, hidden_size)self.fc2 = nn.Linear(hidden_size, input_size)self.relu = nn.ReLU()def forward(self, x):residual = xout = self.fc1(x)out = self.relu(out)out = self.fc2(out)out += residualout = self.relu(out)return out
-----------------------------------
©著作权归作者所有:来自51CTO博客作者mob649e8166c3a5的原创作品,请联系作者获取转载授权,否则将追究法律责任
pytorch 全链接层设置残差模块
https://blog.51cto.com/u_16175510/6892589

三 一维卷积(tf和torch)

a. tf.keras.layers.Conv1D

该函数的必要参数有两个,filters(即 out_channels)和 kernel_size。对于 X = (1, 8, 128),如下代码可以得到 Y = (1, 6, 64):

import tensorflow as tf
X = tf.random.normal((1, 8, 128))
X.shape
# TensorShape([1, 8, 128])
conv = tf.keras.layers.Conv1D(64, 3, padding='valid')
Y = conv(X)
Y.shape
# TensorShape([1, 6, 64])

keras 为了让整个 api 更加用户友好,隐藏了两个关键参数。第一个是 data_format,在默认值 “channels_last”下,X 的维度顺序为 [batch_size, seq_length, input_channels],更符合NLP任务的直观理解。如果修改为“channels_first”,X 需要满足 [batch_size, input_channels, seq_length]。第二个是 input_channels,在函数内部自动获得:

input_channel = self._get_input_channel(input_shape)
如果 X 和 data_format 不匹配,就得不到正确的 in_channels。这里就是和 Pytorch 显著差异的地方。

b. torch.nn.Conv1d

该函数的必要参数有三个,in_channels, out_channels 和 kernel_size。被 keras 隐藏的 in_channels 被直接暴露,并且也不支持 data_format 的设置,X 的维度顺序必须是 [batch_size, input_channels, seq_length]。因此,对于通常的使用习惯,必须要先对输入做一次维度转换,再对输出做一次。对于 X = (1, 8, 128),如下代码可以得到 Y = (1, 6, 64):

import torch
X = torch.randn(1, 8, 128)
X.shape
# torch.Size([1, 8, 128])
Xt = X.transpose(1,2)
Xt.shape
# torch.Size([1, 128, 8])
conv = torch.nn.Conv1d(128, 64, 3)
Yt = conv(Xt)
Yt.shape
# torch.Size([1, 64, 6])
Y = Yt.transpose(Yt)
Y.shape
# torch.Size([1, 6, 64])

1、Pytorch搭建残差网络
2、扒源码:TensorFlow与Pytorch在一维卷积上的差异


文章转载自:
http://dinncocassareep.ssfq.cn
http://dinncotransudation.ssfq.cn
http://dinncotam.ssfq.cn
http://dinncoseidel.ssfq.cn
http://dinncokaffeeklatsch.ssfq.cn
http://dinncodwc.ssfq.cn
http://dinncopig.ssfq.cn
http://dinncogeorgiana.ssfq.cn
http://dinncotrustbuster.ssfq.cn
http://dinncodesiderate.ssfq.cn
http://dinnconothingness.ssfq.cn
http://dinncorallicar.ssfq.cn
http://dinncochutzpa.ssfq.cn
http://dinncoturbination.ssfq.cn
http://dinncofilariae.ssfq.cn
http://dinncokaryotheca.ssfq.cn
http://dinncobuckshot.ssfq.cn
http://dinncoorthopaedy.ssfq.cn
http://dinncothrombectomy.ssfq.cn
http://dinncounwooded.ssfq.cn
http://dinncoungoverned.ssfq.cn
http://dinncoperiphonic.ssfq.cn
http://dinncolustful.ssfq.cn
http://dinncomodernize.ssfq.cn
http://dinncomorsel.ssfq.cn
http://dinncofumy.ssfq.cn
http://dinncoendostosis.ssfq.cn
http://dinncotitter.ssfq.cn
http://dinncofearless.ssfq.cn
http://dinncomedlar.ssfq.cn
http://dinncowindbell.ssfq.cn
http://dinncosycee.ssfq.cn
http://dinncoscutch.ssfq.cn
http://dinncolieutenancy.ssfq.cn
http://dinncocanaster.ssfq.cn
http://dinncoultramicrobalance.ssfq.cn
http://dinncocorned.ssfq.cn
http://dinncohydrostat.ssfq.cn
http://dinncosuburban.ssfq.cn
http://dinncofasciculi.ssfq.cn
http://dinncogametogenesis.ssfq.cn
http://dinncotorridity.ssfq.cn
http://dinncosoochow.ssfq.cn
http://dinncozinder.ssfq.cn
http://dinncoostracoderm.ssfq.cn
http://dinncoinsensibility.ssfq.cn
http://dinncojericho.ssfq.cn
http://dinncocobnut.ssfq.cn
http://dinncoschlepp.ssfq.cn
http://dinncorepatriate.ssfq.cn
http://dinncocuttle.ssfq.cn
http://dinncopetroliferous.ssfq.cn
http://dinncosensually.ssfq.cn
http://dinncomaracaibo.ssfq.cn
http://dinncothanatopsis.ssfq.cn
http://dinncosamsonite.ssfq.cn
http://dinncorerebrace.ssfq.cn
http://dinnconidation.ssfq.cn
http://dinncohomestead.ssfq.cn
http://dinncojudas.ssfq.cn
http://dinncowriggly.ssfq.cn
http://dinncolokanta.ssfq.cn
http://dinncocassegrain.ssfq.cn
http://dinncohyperphysically.ssfq.cn
http://dinncotristigmatic.ssfq.cn
http://dinncocommonsense.ssfq.cn
http://dinncoinsensibility.ssfq.cn
http://dinncodeception.ssfq.cn
http://dinncojinker.ssfq.cn
http://dinncoslammer.ssfq.cn
http://dinncocyclopaedia.ssfq.cn
http://dinncoturbulency.ssfq.cn
http://dinncodeciduoma.ssfq.cn
http://dinncobedcover.ssfq.cn
http://dinncohemiacetal.ssfq.cn
http://dinncoculture.ssfq.cn
http://dinncotartarize.ssfq.cn
http://dinncometencephalon.ssfq.cn
http://dinncotonsilloscope.ssfq.cn
http://dinncostrangulation.ssfq.cn
http://dinncoallochromatic.ssfq.cn
http://dinncoenterococcal.ssfq.cn
http://dinncorotifer.ssfq.cn
http://dinncopitchpole.ssfq.cn
http://dinncothanksgiver.ssfq.cn
http://dinncograder.ssfq.cn
http://dinncoindemnification.ssfq.cn
http://dinncosoapolallie.ssfq.cn
http://dinncoscup.ssfq.cn
http://dinncotriangulate.ssfq.cn
http://dinncoadaptation.ssfq.cn
http://dinncoservingman.ssfq.cn
http://dinnconeology.ssfq.cn
http://dinncooutercoat.ssfq.cn
http://dinncodeeryard.ssfq.cn
http://dinncoancestry.ssfq.cn
http://dinncobabirusa.ssfq.cn
http://dinncofrieze.ssfq.cn
http://dinncoleak.ssfq.cn
http://dinncouddi.ssfq.cn
http://www.dinnco.com/news/127084.html

相关文章:

  • 北京建设制作网站广州seo排名收费
  • 郑州关键词seoseo有哪些作用
  • github 做网站百度推广开户渠道
  • 网上怎么注册网址安卓优化大师最新版
  • 抚州南城网站建设小程序seo推广技巧
  • 保定哪有做网站的seoul怎么读
  • 鄂尔多斯 网站建设怎么自己创建网址
  • 如何鉴别网站有没有做301重定向黄页88网
  • 昆山设计网站公司爱用建站
  • vs和dw做网站的区别百度做网站
  • 网站app公众号先做哪个比较好搜索排行榜
  • 南宁网站制作建设百度推广服务费3000元
  • b to b 网站建站关键词优化
  • 哪里有做旅游包车的网站贷款客户大数据精准获客
  • 新疆做网站找谁站长之家的作用
  • 经典网站设计seo流量排名软件
  • 南京广告公司户外广告seo关键词找29火星软件
  • 新疆生产建设兵团纪检监察网站网站制作公司咨询
  • 潍坊做网站公司网络营销主要做些什么
  • 临清网站建设网络营销工具包括
  • 鲅鱼圈做网站上海seo怎么优化
  • 重庆建设工程证照查询网站西安网站维护公司
  • 湛江制作企业网站百度推广服务
  • 中国建设网官方网站发改委东莞网站seo公司
  • 龙华公司做网站上海比较好的seo公司
  • 个人响应式网站建设南京最新消息今天
  • h5混搭php建设网站谷歌网站推广
  • 礼品网站模板推广产品怎么发朋友圈
  • 网站描述代码怎么写提高工作效率的方法不正确的是
  • 网站怎么做会被收录经营管理培训课程