当前位置:网站首页>Two dimensional convolution -- use of torch.nn.conv2d
Two dimensional convolution -- use of torch.nn.conv2d
2022-07-24 17:28:00 【Program black】
First open the official function , see conv2d How to use .
conv The function consists of three required parameters ,
in_channels Refers to the number of input channels ,out_channels Refers to the number of output channels ,kernel_size Is the number of cores of the convolution kernel ,
There are also some non mandatory parameters . for example padding and stride Parameters , The detailed functions of these two parameters are shown in the following figure .
stride The control is to convolute the rows and columns of several matrices at a time ,padding Is to fill in the data to be processed .
1.padding=0、stride=0 The situation of .

2.padding=2、stride=0 The situation of .
https://github.com/vdumoulin/conv_arithmetic/blob/master/gif/arbitrary_padding_no_strides.gif
3.padding=1、stride=0 The situation of .
conv_arithmetic/same_padding_no_strides.gif at master · vdumoulin/conv_arithmetic · GitHub
about 2 More detailed demonstration of dimensional convolution github link :
conv_arithmetic/README.md at master · vdumoulin/conv_arithmetic · GitHub
adopt debug Code , We can see that the number of channels of our pictures is determined by 3 The passage was turned into 6 passageway , But at the end add tensorboard In the time , Need to be converted to 3 passageway , Therefore use torch.reshape convert .
#coding=utf-8
# Main learning torch.nn.conv2d()
import torch
import torchvision
from torch.utils.data import DataLoader
from PIL import Image
from torch.utils.tensorboard import SummaryWriter
dataset = torchvision.datasets.CIFAR10("./dataset",train=False,transform=torchvision.transforms.ToTensor(),download=True)
dataloader = DataLoader(dataset,batch_size=64)
class this_network(torch.nn.Module):
def __init__(self):
super(this_network,self).__init__()
self.conv1 = torch.nn.Conv2d(in_channels=3,out_channels=6,kernel_size=3,stride=1,padding=0)
def forward(self,x):
x = self.conv1(x)
return x
init_network = this_network()
print(init_network)
writer = SummaryWriter("./logs")
step = 0
for data in dataloader:
imgs,targets = data
output = init_network(imgs)
#print(imgs.shape)
#print(output.shape)
# Use tensorboard Data browsing
writer.add_images("input",imgs,step)
output = torch.reshape(output,(-1,3,30,30))
writer.add_images("output",output,step)
step = step + 1
design sketch

边栏推荐
- NPM install reported -4058 error
- mysql 查询某字段中以逗号分隔的字符串的方法
- TCP协议调试工具TcpEngine V1.3.0使用教程
- Supervisor common commands
- Using unity to do simulation, I don't allow this chart plug-in, you don't know
- [waiting for insurance] what does waiting for insurance rectification mean? What are the rectification contents?
- Rare earth Developer Conference | Apache pulsar committee Liu Dezhi shares the way of cloud native technology transformation
- Is it safe for Mr. qiniu to open a securities account? Can I drive it?
- Exception handling - a small case that takes you to solve NullPointerException
- Summary of ROS master-slave communication experience
猜你喜欢

通道的分离与合并

Demonstration experiment of scrollbar for adjusting image brightness

Canvas from getting started to persuading friends to give up (graphic version)

mysql 查询某字段中以逗号分隔的字符串的方法

Still developing games with unity? Then you're out. Try unity to build an answer system
![[wechat official account H5] authorization](/img/d1/2712f87e134c0b8b8fdeaab9e30492.png)
[wechat official account H5] authorization
Shardingsphere database read / write separation

Atcoder beginer 202 e - count descendants (heuristic merge on heavy chain split tree for offline query)

Iqiyi Tiktok reconciled, Weibo lying gun?

什么是模糊理论,基础,流程
随机推荐
I'll teach you how to use NPs to build intranet penetration services. When you go out, you can easily connect your lightweight notebook to your home game console to play remotely
Code random notes_ Linked list_ 707 design linked list
Iftnews | Christie's launched its venture capital department, aiming at Web3 and metauniverse industries
Portfwd port forwarding
Niuke linked list solution record
AutoCAD - join merge command
Three.js (7): local texture refresh
Mobile robot (IV) four axis aircraft
2022-07-21 Daily: Wu Enda wrote: how to establish projects suitable for AI career
Opencv has its own color operation
[GNN report] Tencent AI Lab Xu TingYang: graph generation model and its application in molecular generation
hcip第三天
Scept: consistent and strategy based trajectory prediction for planned scenarios
nc 端口转发
Kyligence attended the Huawei global smart finance summit to accelerate the expansion of the global market
Is it safe for Mr. qiniu to open a securities account? Can I drive it?
pinia 入门及使用
ROS主从机通信经验总结
Shardingsphere database read / write separation
Yolopose practice: one-stage human posture estimation with hands + code interpretation
