卷积
卷积是特征提取的常用操作,卷积可以改变图片的通道和大小,相比全连接操作,卷积可以减少计算量,并且充分融合图像的局部特征。
import torch
import torch.nn as nn
x = torch.randn(1,1,4,4)
model = nn.Conv2d(in_channels=1,out_channels=1,kernel_size=3,stride=1,padding=0)
output = model(x)
print('output shape',output.shape)
import torch
import torch.nn as nn
x = torch.randn(1,1,5,5)
model = nn.Conv2d(in_channels=1,out_channels=1,kernel_size=4,stride=1,padding=2)
output = model(x)
pr