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

凡科可以做淘客网站吗/安卓手机优化神器

凡科可以做淘客网站吗,安卓手机优化神器,自学制作网站难不难,深圳做网站公司 南山Conv2d、conv2d是pytorch中进行卷积操作的2个类,虽然只是首字母大小写不同,使用起来方法也不一样,一个是类,一个是函数。 1 Conv2d Conv2d是torch.nn中的类 1.1 初始化 CLASS torch.nn.Conv2d(in_channels, out_channels, ker…

Conv2d、conv2d是pytorch中进行卷积操作的2个类,虽然只是首字母大小写不同,使用起来方法也不一样,一个是类,一个是函数。

1 Conv2d

Conv2d是torch.nn中的类

1.1 初始化

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)

参数说明

  • in_channels (int) – 输入图像通道

  • out_channels (int) – 输出图像通道,也就是用了多少层卷积核

  • kernel_size (int or tuple) – 卷积核大小

  • stride (int or tupleoptional) – 步长. Default: 1

  • padding (inttuple or stroptional) – Padding 大小. Default: 0

  • padding_mode (stringoptional) – 填充模式,默认填充0,'zeros''reflect''replicate' or 'circular'. Default: 'zeros'

  • dilation (int or tupleoptional) – Spacing between kernel elements. Default: 1,一般不用管

  • groups (intoptional) – Number of blocked connections from input channels to output channels. Default: 1,一般不用管

  • bias (booloptional) –是否添加偏值, Default: True

 样例

from torch.nn import Conv2d
conv1 = Conv2d(in_channels=3, out_channels=6, kernel_size=3, stride=1, padding=0)
print(conv1)

 输出

Conv2d(3, 6, kernel_size=(3, 3), stride=(1, 1))

 1.2 输入输出大小

Input: (N, C_{in}, H_{in}, W_{in})

Output: (N, C_{out}, H_{out}, W_{out})

  • N:样本数
  • C:通道数
  • H:高
  • W:宽

H_{out}=\left \lfloor \frac{H_{in}+2\times padding[0]-dilation[0]\times (kernelsize[0]-1)-1}{stride[0] }+1 \right \rfloor

W_{out}=\left \lfloor \frac{W_{in}+2\times padding[0]-dilation[0]\times (kernelsize[0]-1)-1}{stride[0] }+1 \right \rfloor

import torch
input = torch.randn(1, 3, 5, 5)
output = conv1(input)
print(input.shape)
print(output.shape)

 输出

torch.Size([1, 3, 5, 5])
torch.Size([1, 6, 3, 3])

2  conv2d

conv2d是torch.nn.functional中的函数

2.1 代码格式

torch.nn.functional.conv2d(input, weight, bias=None, stride=1, padding=0, dilation=1, groups=1) 

参数说明

  • input –输入一个tensor

  • weight – 卷积核,也是一个tensor

  • bias – 偏值,tensor,大小是输出通道的大小. Default: None

  • stride –步长. Default: 1

  • padding –{‘valid’, ‘same’},默认valid,,也可以是int数值

  • dilation – the spacing between kernel elements. Can be a single number or a tuple (dH, dW). Default: 1,不用管

  • groups – split input into groups, \text{in\_channels}in_channels should be divisible by the number of groups. Default: 1,不用管

2.2 输入输出大小

input = torch.tensor([[1, 2, 0, 3, 1],[0, 1, 3, 3, 1],[1, 2, 1, 0, 0],[5, 5, 3, 1, 4],[3, 1, 0, 4, 1]])kernel = torch.tensor([[1, 1, 1],[0, 2, 0],[2, 1, 0]])input = torch.reshape(input, (1, 1, 5, 5))
kernel = torch.reshape(kernel, (1, 1, 3, 3))print(input.shape)
print(kernel.shape)

输出

torch.Size([1, 1, 5, 5])
torch.Size([1, 1, 3, 3])

样例 

import torch.nn.functional as F
output = F.conv2d(input, kernel, stride=1, padding=“same”)
print(output)

输出

tensor([[[[ 1,  3,  4, 10,  8],[ 5, 10, 12, 12,  6],[ 7, 18, 16, 16,  8],[11, 13,  9,  3,  4],[14, 13,  9,  7,  4]]]])
http://www.jmfq.cn/news/5273083.html

相关文章:

  • 怎么给做的网站做百度搜索/怎么创建一个网址
  • 郑州网站建设预订/做一个推广网站大概多少钱
  • 网站接入服务商是什么/网络培训心得体会总结
  • 佛山网站制作建设/2023年7 8月十大新闻
  • b2b网站建设方案/企业网站建设报价表
  • 深圳建设网站费用/朝阳网站seo
  • 黄骅网站建设/google官网
  • 网站开发能用udp协议吗/市场调研的方法有哪些
  • 深圳企搜网站建设/网络营销的内涵
  • wordpress电影采集/seo研究中心倒闭
  • 南通网站建设排名公司/网站快速优化排名软件
  • 天津 交友 网站建设/在线crm
  • 桂林小学网站建设/品牌营销公司
  • p2p网上贷款网站建设方案.docx/seoaoo
  • 蚌埠百度做网站/社群营销是什么意思
  • 济南企业网站制/搜索广告是什么意思
  • 有独立IP如何建设网站/百度推广关键词排名规则
  • 免费的网站生成app/网站网络营销公司
  • 个人网站怎么设计/重庆网站推广软件
  • 怎么做淘宝网站赚钱技巧/竞价排名采用什么计费方式
  • 网站的域名分为哪些/珠海百度seo
  • 湛江网站设计/灯塔网站seo
  • 网站用什么做备份/seo策略分析
  • 做亚马逊运营要看哪些网站/b站怎么推广
  • 设计网站的一般过程/产品推广活动策划方案
  • 江门网站开发/成免费的crm
  • 娱乐彩票网站建设制作/手机百度电脑版入口
  • 做企业网站设计价格是多少/网络营销比较常用的营销模式
  • wp网站打开太慢怎么做优化/合肥网络公司排名
  • 网站添加悬浮二维码/视频外链平台