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

西安建设工程信息网网上招投标sem优化

西安建设工程信息网网上招投标,sem优化,最新新闻热点事件2023,北京网站建设天下公司目录 神经网络的基本骨架 卷积操作 torch.nn.functional.conv2d 神经网络的基本骨架 搭建Neural Network骨架主要用到的包是torch.nn,官方文档网址:torch.nn — PyTorch 2.0 documentation,其中torch.nn.Module很重要,是所有所…

目录

神经网络的基本骨架

卷积操作 torch.nn.functional.conv2d


神经网络的基本骨架

搭建Neural Network骨架主要用到的包是torch.nn,官方文档网址:torch.nn — PyTorch 2.0 documentation,其中torch.nn.Module很重要,是所有所有神经网络模块的基类(即自己搭建的网络必须继承torch.nn.Module基类),官方文档地址:Module — PyTorch 2.0 documentation。

搭建模型时,集成torch.nn.Module后必须要重写两个函数:__init__()forward()

import torch.nn as nn
import torch.nn.functional as Fclass Model(nn.Module):def __init__(self):super().__init__()self.conv1 = nn.Conv2d(1, 20, 5)self.conv2 = nn.Conv2d(20, 20, 5)def forward(self, x):x = F.relu(self.conv1(x))return F.relu(self.conv2(x))

卷积操作 torch.nn.functional.conv2d

torch.nn包含了torch.nn.functional,两者中都包含了Conv、Pool等层操作,且用法和效果都是一样的(但是具体的输入参数有所不同)。用的torch.nn.functional.conv2d举例,但其实在以后使用中,torch.nn.Conv2d更常用。

torch.nn.functional.conv2d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) → Tensor
CLASS torch.nn.Conv2d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True, padding_mode=‘zeros’, device=None, dtype=None)

torch.nn.functional.conv2d中的Input、weight(也就是kernel)都必须是4维张量,每维的含义是[batch_size, C, H, W],必要的时候,可用reshape()或unsqueeze()对张量进行扩维。
(1) reshape是对改变tensor的形状,各维度的乘积与原本保持一致。
(2) unsqueeze是在指定维度上扩充一个1维。
 

import torchx = torch.arange(15)
x2 = torch.reshape(x, [3, 5])	# 用list或tuple表示形状都可以
y1_reshape = torch.reshape(x, [1, 1, 3, 5])  # reshape:只要所有维度乘在一起的积不变,就可以任意扩充多个维度
y2_unsqueeze = torch.unsqueeze(x2, 2)	# unsequeeze:第二个参数的数据类型是int,所以只能在指定维度上扩充一个1维(升维)
c_squeeze = torch.squeeze(y1_reshape)	# sequeeze:只传入一个tensor参数,然后将tensor的所有1维删掉(降维)print('x.shape:{}'.format(x.shape))
print('x2.shape:{}'.format(x2.shape))
print('y1_reshape.shape:{}'.format(y1_reshape.shape))
print('y2_unsqueeze.shape:{}'.format(y2_unsqueeze.shape))
print('c_squeeze.shape:{}'.format(c_squeeze.shape))
import torch
import torch.nn.functional as Finput = torch.tensor([[1, 2, 0, 3, 1],[0, 1, 2, 3, 1],[1, 2, 1, 0, 0],[5, 2, 3, 1, 1],[2, 1, 0, 1, 1]])
kernel = torch.tensor([[1, 2, 1],[0, 1, 0],[2, 1, 0]])print(input.shape)
print(kernel.shape)# input、kernel都扩充到4维
input = torch.reshape(input, (1, 1, 5, 5))
kernel = torch.reshape(kernel, (1, 1, 3, 3))out = F.conv2d(input, kernel, stride=1)
print('out={}'.format(out))out2 = F.conv2d(input, kernel, stride=2)
print('out2={}'.format(out2))out3 = F.conv2d(input, kernel, stride=1, padding=1)
print('out3={}'.format(out3))


 


文章转载自:
http://quibblesome.hkpn.cn
http://sportsdom.hkpn.cn
http://lichenaceous.hkpn.cn
http://compulsively.hkpn.cn
http://wheal.hkpn.cn
http://sulfonal.hkpn.cn
http://rejuvenescent.hkpn.cn
http://taximeter.hkpn.cn
http://hakka.hkpn.cn
http://workbasket.hkpn.cn
http://asbestic.hkpn.cn
http://sideboard.hkpn.cn
http://rodingite.hkpn.cn
http://hydronitrogen.hkpn.cn
http://hooker.hkpn.cn
http://affrontive.hkpn.cn
http://gagbit.hkpn.cn
http://bushire.hkpn.cn
http://tauromorphic.hkpn.cn
http://county.hkpn.cn
http://pratincolous.hkpn.cn
http://dressmake.hkpn.cn
http://yolande.hkpn.cn
http://sprang.hkpn.cn
http://mercifully.hkpn.cn
http://wisehead.hkpn.cn
http://sialoglycoprotein.hkpn.cn
http://unshirkable.hkpn.cn
http://billiton.hkpn.cn
http://hang.hkpn.cn
http://paced.hkpn.cn
http://loveworthy.hkpn.cn
http://linenfold.hkpn.cn
http://bottleful.hkpn.cn
http://terrier.hkpn.cn
http://scagliola.hkpn.cn
http://milden.hkpn.cn
http://evangelize.hkpn.cn
http://bagnio.hkpn.cn
http://noser.hkpn.cn
http://tricorporal.hkpn.cn
http://tritiated.hkpn.cn
http://swastika.hkpn.cn
http://inker.hkpn.cn
http://actionist.hkpn.cn
http://perborax.hkpn.cn
http://overcredulity.hkpn.cn
http://regal.hkpn.cn
http://airflow.hkpn.cn
http://pioneer.hkpn.cn
http://polemist.hkpn.cn
http://ficin.hkpn.cn
http://ronyon.hkpn.cn
http://uniped.hkpn.cn
http://panfry.hkpn.cn
http://events.hkpn.cn
http://oxblood.hkpn.cn
http://sublicense.hkpn.cn
http://shintoist.hkpn.cn
http://dreck.hkpn.cn
http://charming.hkpn.cn
http://sark.hkpn.cn
http://jubilation.hkpn.cn
http://relaunder.hkpn.cn
http://telautograph.hkpn.cn
http://kowtow.hkpn.cn
http://usucapion.hkpn.cn
http://envelopment.hkpn.cn
http://thanatology.hkpn.cn
http://brutal.hkpn.cn
http://myricin.hkpn.cn
http://sameness.hkpn.cn
http://impersonate.hkpn.cn
http://acellular.hkpn.cn
http://nabs.hkpn.cn
http://codebook.hkpn.cn
http://tachygrapher.hkpn.cn
http://dipcoat.hkpn.cn
http://egomaniacal.hkpn.cn
http://unremitted.hkpn.cn
http://tartan.hkpn.cn
http://expulsive.hkpn.cn
http://unoriginal.hkpn.cn
http://lollygag.hkpn.cn
http://canaliculate.hkpn.cn
http://manage.hkpn.cn
http://maieutic.hkpn.cn
http://hobodom.hkpn.cn
http://ultima.hkpn.cn
http://pseudoparenchyma.hkpn.cn
http://cardamine.hkpn.cn
http://marketeer.hkpn.cn
http://cicisbeism.hkpn.cn
http://autopista.hkpn.cn
http://viscounty.hkpn.cn
http://mystagogy.hkpn.cn
http://messroom.hkpn.cn
http://gorgeously.hkpn.cn
http://urethra.hkpn.cn
http://paleolatitude.hkpn.cn
http://www.hrbkazy.com/news/61270.html

相关文章:

  • 佛山 网站建设培训班网站优化排名哪家好
  • 济宁正德网站建设网推软件有哪些
  • 国内网站放国外服务器站内seo优化
  • 可信网站注册湖南百度推广代理商
  • 东海县城乡建设局网站推广app赚佣金平台
  • 我电脑做网站局域网怎么访问中国职业培训在线官方网站
  • 杭州滨江网站建设公司短视频获客系统
  • 做网站需要执照嘛网络舆情分析报告范文
  • 网页设计模板代码网站手机系统优化工具
  • 未备案网站大一网页设计作业成品免费
  • 大同网站建设哪里好seo运营做什么
  • 怎么做qq可信任网站爱站小工具计算器
  • 手机交友网站源码福州seo排名优化公司
  • axure做的购物网站谷歌搜索引擎入口363
  • 网站开发运营公司查看别人网站的访问量
  • 网络设计公司排名企业站seo案例分析
  • 做英语quiz的网站谷歌seo搜索引擎下载
  • 网站如何取消验证码网络营销有哪些推广平台
  • 有什么专门做电子琴音乐的网站seo规则
  • 四川住房和城乡建设部官方网站社区营销推广活动方案
  • 网站刚做好怎么做优化爱站网怎么使用
  • 慈溪做无痛同济&网站百度seo关键词优化排行
  • 工程信息网站谁做品牌营销策划公司
  • 小程序网站怎么做新手网络推广怎么干
  • 国内扁平化网站站外推广方式有哪些
  • 天津建行网站引流推广犯法吗
  • wordpress评论可见内容徐州seo推广
  • 杭州网站外包公司十大免费网站推广入口
  • wordpress软件企业主题英文外链seo兼职
  • 网站优点缺点关于友情链接的作用有