PyTorch实现的ResNeXt

网友投稿 534 2022-08-31

PyTorch实现的ResNeXt

PyTorch实现的ResNeXt

Aggregated Residual Transformations for Deep Neural Networks PDF: ​​​PyTorch代码: ​​ResNeXtBlock(nn.Module): def __init__(self,in_places,places, stride=1,downsampling=False, expansion = 2, cardinality=32): super(ResNeXtBlock,self).__init__() self.expansion = expansion self.downsampling = downsampling self.bottleneck = nn.Sequential( nn.Conv2d(in_channels=in_places, out_channels=places, kernel_size=1, stride=1, bias=False), nn.BatchNorm2d(places), nn.ReLU(inplace=True), nn.Conv2d(in_channels=places, out_channels=places, kernel_size=3, stride=stride, padding=1, bias=False, groups=cardinality), nn.BatchNorm2d(places), nn.ReLU(inplace=True), nn.Conv2d(in_channels=places, out_channels=places * self.expansion, kernel_size=1, stride=1, bias=False), nn.BatchNorm2d(places * self.expansion), ) if self.downsampling: self.downsample = nn.Sequential( nn.Conv2d(in_channels=in_places, out_channels=places * self.expansion, kernel_size=1, stride=stride,bias=False), nn.BatchNorm2d(places * self.expansion) ) self.relu = nn.ReLU(inplace=True) def forward(self, x): residual = x out = self.bottleneck(x) if self.downsampling: residual = self.downsample(x) out += residual out = self.relu(out) return

可以直接将VGG 和 ResNet中的Block换做 ResNeXt block

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Go语言的前景分析(go语言适合做数据分析吗)
下一篇:注意力机制论文:Squeeze-and-Excitation Networks及其PyTorch实现
相关文章

 发表评论

暂时没有评论,来抢沙发吧~