DDR爱好者之家 Design By 杰米

3*3卷积核与2*5卷积核对神经元大小的设置

#这里kerner_size = 2*5
class CONV_NET(torch.nn.Module): #CONV_NET类继承nn.Module类
 def __init__(self):
  super(CONV_NET, self).__init__() #使CONV_NET类包含父类nn.Module的所有属性
  # super()需要两个实参,子类名和对象self
  self.conv1 = nn.Conv2d(1, 32, (2, 5), 1, padding=0)
  self.conv2 = nn.Conv2d(32, 128, 1, 1, padding=0)
  self.fc1 = nn.Linear(512, 128)
  self.relu1 = nn.ReLU(inplace=True)
  self.drop1 = nn.Dropout(0.5)
  self.fc2 = nn.Linear(128, 32)
  self.relu2 = nn.ReLU(inplace=True)
  self.fc3 = nn.Linear(32, 3)
  self.softmax = nn.Softmax(dim=1)

 def forward(self, x):
  x = self.conv1(x)
  x = self.conv2(x)
  x = x.view(x.size(0), -1)
  x = self.fc1(x)
  x = self.relu1(x)
  x = self.drop1(x)
  x = self.fc2(x)
  x = self.relu2(x)
  x = self.fc3(x)
  x = self.softmax(x)
  return x

主要看对称卷积核以及非对称卷积核之间的计算方式

#这里kerner_size = 3*3
class CONV_NET(torch.nn.Module): #CONV_NET类继承nn.Module类
 def __init__(self):
  super(CONV_NET, self).__init__() #使CONV_NET类包含父类nn.Module的所有属性
  # super()需要两个实参,子类名和对象self
  self.conv1 = nn.Conv2d(1, 32, 3, 1, padding=1)
  self.conv2 = nn.Conv2d(32, 128, 1, 1, padding=0)
  self.fc1 = nn.Linear(3200, 128)
  self.relu1 = nn.ReLU(inplace=True)
  self.drop1 = nn.Dropout(0.5)
  self.fc2 = nn.Linear(128, 32)
  self.relu2 = nn.ReLU(inplace=True)
  self.fc3 = nn.Linear(32, 3)
  self.softmax = nn.Softmax(dim=1)

 def forward(self, x):
  x = self.conv1(x)
  x = self.conv2(x)
  x = x.view(x.size(0), -1)
  x = self.fc1(x)
  x = self.relu1(x)
  x = self.drop1(x)
  x = self.fc2(x)
  x = self.relu2(x)
  x = self.fc3(x)
  x = self.softmax(x)
  return x

针对kerner_size=2*5,padding=0,stride=1以及kerner_size=3*3,padding=1,stride=1二者计算方式的比较如图所示

浅谈pytorch卷积核大小的设置对全连接神经元的影响

以上这篇浅谈pytorch卷积核大小的设置对全连接神经元的影响就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持。

DDR爱好者之家 Design By 杰米
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
DDR爱好者之家 Design By 杰米