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

北京建设工程信息网站做门图网站

北京建设工程信息网站,做门图网站,黄石本土做网站的公司,辽宁省营商环境建设局 网站目录 神经网络的基本骨架 卷积操作 torch.nn.functional.conv2d 神经网络的基本骨架 搭建Neural Network骨架主要用到的包是torch.nn#xff0c;官方文档网址#xff1a;torch.nn — PyTorch 2.0 documentation#xff0c;其中torch.nn.Module很重要#xff0c;是所有所…目录 神经网络的基本骨架 卷积操作 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, biasNone, stride1, padding0, dilation1, groups1) → Tensor CLASS torch.nn.Conv2d(in_channels, out_channels, kernel_size, stride1, padding0, dilation1, groups1, biasTrue, padding_mode‘zeros’, deviceNone, dtypeNone)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, stride1) print(out{}.format(out))out2 F.conv2d(input, kernel, stride2) print(out2{}.format(out2))out3 F.conv2d(input, kernel, stride1, padding1) print(out3{}.format(out3))
http://wiki.neutronadmin.com/news/426330/

相关文章:

  • 牙科网站开发罗湖网站制作公司
  • 菏泽网站建设fuyucom网站建设情况简介
  • 做app做网站从何学起中国住房和建设部网站
  • 不同性质网站的营销特点一览表中国第八冶金建设公司网站
  • 如何快速自己做网站淘客网站建设
  • 前端网站页面模板北京seo推广优化
  • 三亚网站建设网站建设廴金手指花总壹柒
  • 做国外进口衣服的网站好成都交易网站建设
  • 建站快车源码新闻头条最新消息今天
  • 怎么用ip地址做网站国内做视频网站需要啥
  • 智能手机网站模板招聘设计师去哪个网站
  • 合肥网站建设步骤修改wordpress版权
  • 素材网站wordpress管理工具栏
  • 建立网站需要多少钱一个html php网站开发报告
  • 佛山营销型网站建设网站建设与网页设计案例教程
  • 做推广网站客户求购平台
  • 泉州网页网站制作卡点视频免费制作软件
  • 找个为公司做网站的在线建设网站制作
  • 做网站先做前台还是后台化妆品销售网站的源代码
  • 做电商网站要备案吗商河便宜做网站的公司
  • 网站分几种类型南京建设人才网站
  • 宣城网站 建设深圳营销策划公司
  • 网站开发和桌面开发哪个难淮南建网站公司
  • 教师招聘网站长城建设集团墙外必去的网站
  • 云上网站做等保如何使网站能被百度搜到
  • 郑州网站开发hndlwxf006网站建设
  • 金融公司网站模板WordPress优惠券主题
  • python 网站开发实例大型集团网站建设
  • 网站开发 语音wordpress安装语言
  • 泰安中商网络做的网站怎么进入内网建站教程