Resnet之后的模型
时间: 2025-02-22 21:27:50 浏览: 15
深度学习模型的发展历程
自ResNet发布以来,深度学习领域经历了快速的发展,出现了多个具有创新性的网络结构。这些新模型不仅提升了性能,在效率方面也有所改进。
Sequeeze-and-Excitation Networks (SENet)
SENet引入了一种新的模块——Squeeze-and-Excitation block,该模块能够自动学习不同channel的重要性并重新加权[^6]。这种机制使得网络可以更专注于重要的特征图,从而提高了识别精度。
import torch.nn as nn
class SELayer(nn.Module):
def __init__(self, channel, reduction=16):
super(SELayer, self).__init__()
self.avg_pool = nn.AdaptiveAvgPool2d(1)
self.fc = nn.Sequential(
nn.Linear(channel, channel // reduction),
nn.ReLU(inplace=True),
nn.Linear(channel // reduction, channel),
nn.Sigmoid()
)
def forward(self, x):
b, c, _, _ = x.size()
y = self.avg_pool(x).view(b, c)
y = self.fc(y).view(b, c, 1, 1)
return x * y.expand_as(x)
Dense Convolutional Network (DenseNet)
不同于传统的卷积神经网络中层与层之间仅存在局部连接关系,DenseNet提出了密集连接的概念,即每一层都与其他所有层直接相连[^7]。这样的设计有助于缓解梯度消失问题,并促进了特征传播。
from torchvision import models
model = models.densenet121(pretrained=True)
for param in model.parameters():
param.requires_grad = False
classifier = nn.Sequential(
nn.Linear(model.classifier.in_features, 500),
nn.ReLU(),
nn.Dropout(0.4),
nn.Linear(500, num_classes),
nn.LogSoftmax(dim=1))
model.classifier = classifier
EfficientNet
EfficientNet系列通过对宽度、深度以及分辨率三个维度进行复合缩放来构建更加高效的网络架构[^8]。这种方法能够在保持计算量不变的情况下显著提升模型的表现力。
efficientnet_b0 = models.efficientnet_b0(pretrained=True)
num_ftrs = efficientnet_b0.classifier[1].in_features
efficientnet_b0.classifier[1] = nn.Linear(num_ftrs, num_classes)
阅读全文
相关推荐


















