{"id":55793,"date":"2025-08-14T08:34:39","date_gmt":"2025-08-14T00:34:39","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/55793.html"},"modified":"2025-08-14T08:34:39","modified_gmt":"2025-08-14T00:34:39","slug":"%e6%89%8b%e6%8a%8a%e6%89%8b%e6%95%99%e4%bd%a0%e5%a6%82%e4%bd%95%e5%a4%8d%e7%8e%b0%e5%88%ab%e4%ba%ba%e7%9a%84%e8%ae%ba%e6%96%87%ef%bc%88cnn%e7%9b%b8%e5%85%b3%ef%bc%89%ef%bc%88%e4%be%8b%ef%bc%9a","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/55793.html","title":{"rendered":"\u624b\u628a\u624b\u6559\u4f60\u5982\u4f55\u590d\u73b0\u522b\u4eba\u7684\u8bba\u6587\uff08CNN\u76f8\u5173\uff09\uff08\u4f8b\uff1a\u57fa\u4e8e\u96c6\u6210\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u548c Vit \u7684\u773c\u5e95\u56fe\u50cf\u5206\u7c7b\u7814\u7a76\uff09"},"content":{"rendered":"<\/p>\n<h2>\u524d\u8a00<\/h2>\n<p> \u5b66\u4e60\u4ed6\u4eba&#xff0c;\u63d0\u5347\u81ea\u5df1\u3002\u8d85\u8d8a\u4ed6\u4eba&#xff0c;\u5b9e\u73b0\u521b\u65b0\u3002<\/p>\n<p>\u672c\u6587\u5c06\u5c55\u73b0 \u5982\u4f55\u4e00\u6b65\u4e00\u6b65\u7684\u590d\u73b0\u4ed6\u4eba\u7684\u6587\u7ae0\u3002\u6ca1\u6709\u5e9f\u8bdd&#xff0c;\u5168\u662f\u5b9e\u64cd\u3002\u8be6\u7ec6\u5c55\u793a\u8bba\u6587\u4ee3\u7801\u590d\u73b0\u7684\u6d41\u7a0b\u3002<\/p>\n<\/p>\n<p>\u672c\u6587\u590d\u73b0\u7684\u6587\u7ae0\u6765\u81ea&#xff1a;<\/p>\n<p>\u8881\u5a9b, \u9648\u660e\u60e0, \u67ef\u8212\u5a77, \u7b49. \u57fa\u4e8e\u96c6\u6210\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u548c Vit \u7684\u773c\u5e95\u56fe\u50cf\u5206\u7c7b\u7814\u7a76[J]. Chinese Journal of Lasers, 2022, 49(20): 2007205-2007205-9.<\/p>\n<p>\u6807\u9898<\/p>\n<\/p>\n<p>&#xff08;\u76f8\u5173\u9886\u57df&#xff0c;\u60f3\u590d\u73b0\u7684\u6587\u7ae0&#xff0c;\u8bf7\u53d1\u5728\u8bc4\u8bba\u533a&#xff0c;\u53ef\u5e2e\u590d\u73b0\u3002\u70b9\u4e2a\u5173\u6ce8\u5148&#xff09;<\/p>\n<\/p>\n<p>\u89c2\u770b\u672c\u6587&#xff0c;\u8981\u6709\u4e00\u5b9aCNN\u57fa\u7840\u3002\u6ca1\u6709\u53ef\u8df3\u94fe\u63a5&#xff1a;<\/p>\n<p>\u5c0f\u767d\u5feb\u901f\u4e0a\u624b\u5b9e\u64cdCNN\u56fe\u50cf\u5206\u7c7b&#xff08;pytorch&#xff09;\u3002\u770b\u5b8c\u79d2\u53d8\u5927\u795e\u3002_cnn\u56fe\u50cf\u7f16\u7a0b\u600e\u4e48\u5b66-CSDN\u535a\u5ba2<\/p>\n<\/p>\n<h2>1.\u901a\u8bfb\u8bba\u6587<\/h2>\n<\/p>\n<p>\u201c\u672c\u6587\u63d0\u51fa\u4e00\u79cd\u57fa\u4e8eEfficientNet-Vit\u96c6\u6210\u6a21\u578b\u7684\u773c\u5e95\u56fe\u50cf\u5206\u7c7b\u65b9\u6cd5,\u6b64 \u65b9\u6cd5\u5c06\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u6a21\u578bEfficientNetV2-S\u548cVit\u6a21\u578b\u76f8\u7ed3\u5408,\u5206\u522b\u4f7f\u7528\u4e24\u79cd\u5b8c\u5168\u4e0d\u540c\u7684\u65b9\u6cd5\u63d0\u53d6\u773c\u5e95\u56fe\u50cf\u7684\u7279 \u5f81,\u901a\u8fc7\u81ea\u9002\u5e94\u52a0\u6743\u878d\u5408\u7b97\u6cd5\u8ba1\u7b97\u5f97\u5230\u6700\u4f18\u52a0\u6743\u56e0\u5b500.6\u548c0.4,\u5229\u7528\u52a0\u6743\u8f6f\u6295\u7968\u6cd5\u8fdb\u884c\u6a21\u578b\u96c6\u6210,\u4ece\u800c\u83b7\u5f97\u66f4\u597d \u7684\u5206\u7c7b\u7ed3\u679c\u3002\u201d<\/p>\n<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u6b64\u6587\u501f\u9274\u4e862\u4e2d\u6a21\u578bEfficientNet\u548cVit&#xff0c;\u7136\u540e\u901a\u8fc7\u4e00\u79cd\u6240\u8c13\u7684\u52a0\u6743\u8f6f\u6295\u7968\u6cd5\u8fdb\u884c\u6a21\u578b\u96c6\u6210&#xff0c;<\/p>\n<p>\u8fd9\u4e48\u9ad8\u5927\u4e0a\u7684\u8bcd&#xff1a;\u52a0\u6743\u8f6f\u6295\u7968\u6cd5<\/p>\n<p>\u8bf4\u767d\u4e86\u5c31\u662f2\u4e2a\u6a21\u578b\u8f93\u51fa\u7684\u7c7b\u522b\u6982\u7387 \u52a0\u8d77\u6765\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"86\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250814003436-689d2f1cd8585.png\" width=\"702\" \/><\/p>\n<\/p>\n<p>\u4f8b\u5982&#xff0c;<\/p>\n<p>\u7c7b\u522b A,B,C,D,E\u3002<\/p>\n<p>\u6837\u672cX&#xff0c;<\/p>\n<p>\u5728model1 \u4e0a\u7684 5\u4e2a\u7c7b\u522b\u7684\u6982\u7387\u5206\u522b\u662f&#xff1a;0.1 &#xff0c;0.2&#xff0c; 0.3 &#xff0c;0.15 &#xff0c;0.25&#xff0c;\u6240\u4ee5X\u5728model1\u4e0a\u7684\u7c7b\u522b \u4e3aC\u3002<\/p>\n<p>\u5728model2\u00a0\u4e0a\u7684 5\u4e2a\u7c7b\u522b\u7684\u6982\u7387\u5206\u522b\u662f&#xff1a;0.15 &#xff0c;0.35&#xff0c; 0.1 &#xff0c;0.1\u00a0&#xff0c;0.3&#xff0c;\u6240\u4ee5X\u5728model2\u4e0a\u7684\u7c7b\u522b \u4e3aB\u3002<\/p>\n<p>\u901a\u8fc7\u52a0\u6743\u8f6f\u6295\u7968\u6cd5\u5f97\u5230&#xff1a;\u6837\u672cX&#xff0c;5\u4e2a\u7c7b\u522b\u7684\u6982\u7387\u5206\u522b\u662f&#xff1a;<\/p>\n<p>0.1&#215;0.6&#043;0.15&#215;0.4\u00a0 \u00a00.2&#215;0.6&#043;0.35&#215;0.4\u00a0 \u00a0 \u00a0 0.3&#215;0.6&#043;0.1&#215;0.4\u00a0 \u00a0 0.15&#215;0.6&#043;0.1&#215;0.4\u00a0 0.25&#215;0.6&#043;0.3&#215;0.4<\/p>\n<p>\u5373&#xff0c;0.12\u00a0 \u00a00.26\u00a0 0.22\u00a0 0.13\u00a0 0.27<\/p>\n<p>\u6240\u4ee5\u6700\u7ec8\u8f93\u51fa\u7684\u7c7b\u522b \u4e3aD\u3002<\/p>\n<\/p>\n<p>\u53e6\u5916&#xff0c;\u6700\u4f18\u52a0\u6743\u56e0\u5b500.6\u548c0.4,\u901a\u8fc7\u81ea\u9002\u5e94\u52a0\u6743\u878d\u5408\u7b97\u6cd5\u8ba1\u7b97\u5f97\u5230\u3002<\/p>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"703\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250814003436-689d2f1cef585.png\" width=\"550\" \/><\/p>\n<p>\u5927\u6982\u662f\u901a\u8fc7 \u6982\u7387\u7684\u5206\u5e03 \u8ba1\u7b97\u65b9\u5dee&#xff0c;\u6765\u5f97\u5230\u7684\u3002<\/p>\n<\/p>\n<p>\u4e3a\u4e86\u589e\u52a0\u521b\u65b0\u70b9&#xff0c;\u6587\u7ae0 \u8fd8\u5bf9EfficientNet&#xff0c;\u505a\u4e86\u6539\u8fdb\u3002<\/p>\n<p>\u6539\u8fdb\u5982\u4e0b&#xff1a;<\/p>\n<p>\u672c\u7814\u7a76\u4f7f\u7528\u4e00\u79cd\u65e0\u53c2\u6570\u6ce8\u610f\u529b\u6a21\u5757SimAM&#xff0c;\u66ff\u6362Fused-MBConv\u7684SE\u6a21\u5757<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"378\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250814003437-689d2f1d1a5b3.png\" width=\"466\" \/><\/p>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"313\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250814003437-689d2f1d3b651.png\" width=\"1108\" \/><\/p>\n<\/p>\n<h2>2.\u5173\u952e\u6280\u672f-\u52a0\u6743\u8f6f\u6295\u7968\u6cd5<\/h2>\n<p> \u00a0<\/p>\n<p>EfficientNet\u548cVit\u90fd\u53ef\u4ee5\u5728torchvision.models\u4e2d\u76f4\u63a5\u8c03\u7528\u3002<\/p>\n<p>model1 &#061; torchvision.models.vit_b_16(pretrained&#061;True)<br \/>\nmodel1.heads.head &#061; nn.Linear(model1.heads.head.in_features, 5)<\/p>\n<p>model2 &#061; torchvision.models.efficientnet_v2_m(pretrained&#061;True)<br \/>\nmodel2.classifier[1] &#061; nn.Linear(in_features&#061;1280, out_features&#061;5) <\/p>\n<p>\u4f46\u9700\u8981\u6ce8\u610f\u4fee\u6539&#xff0c;\u7c7b\u522b\u6570\u91cf\u3002<\/p>\n<p>\u7528pytorch\u7684torchvision.models\u8c03\u7528\u5404\u79cdcnn\u6a21\u578b&#xff0c;\u8bad\u7ec3\u81ea\u5df1\u7684\u6570\u636e\u96c6\u65f6&#xff0c;\u600e\u4e48\u624b\u52a8\u6539\u5206\u7c7b\u6570num_classes\u3002_torchvision \u5e38\u89c1\u6a21\u578b\u8c03\u7528-CSDN\u535a\u5ba2<\/p>\n<p>\u5b8c\u6574\u4ee3\u7801\u5982\u4e0b&#xff1a;<\/p>\n<p>import torch.nn as nn<br \/>\nimport torch<br \/>\nfrom torchvision import transforms<br \/>\nimport torchvision<br \/>\nfrom PIL import Image<br \/>\nimport torch.nn.functional as F <\/p>\n<p>label_dic &#061; {0:&#034;A&#034;,1:&#034;B&#034;,2:&#034;C&#034;,3:&#034;D&#034;,4:&#034;E&#034;}<\/p>\n<p>def usemodel_singleimg(model, test_image):<br \/>\n    transformer &#061; transforms.Compose([<br \/>\n        transforms.Resize((224, 224)),<br \/>\n        transforms.ToTensor(),<br \/>\n        transforms.Normalize(mean&#061;[0.5, 0.5, 0.5],<br \/>\n                             std&#061;[0.5, 0.5, 0.5])<br \/>\n    ])<\/p>\n<p>    device &#061; torch.device(&#034;cuda&#034; if torch.cuda.is_available() else &#034;cpu&#034;)<br \/>\n    model.to(device)<\/p>\n<p>    test_image &#061; test_image.convert(&#034;RGB&#034;)<br \/>\n    processed_image &#061; transformer(test_image).unsqueeze(dim&#061;0)<br \/>\n    processed_image &#061; processed_image.to(device)<\/p>\n<p>    model.eval()<\/p>\n<p>    with torch.no_grad():<br \/>\n        output &#061; model(processed_image)<\/p>\n<p>        # \u65b0\u589e\u6982\u7387\u8ba1\u7b97\u90e8\u5206<br \/>\n        probabilities &#061; F.softmax(output, dim&#061;1)  # \u6cbf\u7c7b\u522b\u7ef4\u5ea6\u505asoftmax<br \/>\n        probabilities &#061; probabilities.cpu().numpy()[0]  # \u8f6c\u4e3anumpy\u6570\u7ec4\u5e76\u53bb\u6389batch\u7ef4\u5ea6<\/p>\n<p>        _, predicted &#061; torch.max(output.data, 1)<br \/>\n        class_id &#061; predicted.item()#\u9884\u6d4b\u7c7b\u522bID<\/p>\n<p>    return probabilities.tolist()<\/p>\n<p>def add(model1,model2,img):<br \/>\n    probabilities1 &#061; usemodel_singleimg(model1, img)<br \/>\n    probabilities2 &#061; usemodel_singleimg(model2, img)<br \/>\n    sum_probabilities &#061; []<br \/>\n    for i in range(5):<br \/>\n        sum_probabilities.append(probabilities1[i]*0.6&#043;probabilities2[i]*0.4)<\/p>\n<p>    return sum_probabilities<\/p>\n<p>def label_sum_probabilities(lst):<br \/>\n    max_val &#061; max(lst)<br \/>\n    label &#061; label_dic[lst.index(max_val)]<br \/>\n    return label<\/p>\n<p>if __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    model1 &#061; torchvision.models.vit_b_16(pretrained&#061;True)<br \/>\n    model1.heads.head &#061; nn.Linear(model1.heads.head.in_features, 5)<\/p>\n<p>    model2 &#061; torchvision.models.efficientnet_v2_m(pretrained&#061;True)<br \/>\n    model2.classifier[1] &#061; nn.Linear(in_features&#061;1280, out_features&#061;5)<\/p>\n<p>    # \u52a0\u8f7d\u6d4b\u8bd5\u56fe\u7247<br \/>\n    img &#061; Image.open(&#034;cat.png&#034;)<\/p>\n<p>    result &#061; add(model1,model2,img)<br \/>\n    print(result)<br \/>\n    label &#061; label_sum_probabilities(result)<br \/>\n    print(label)<\/p>\n<p>\u8fd0\u884c\u540e&#xff0c;\u8f93\u51fa<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"256\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250814003437-689d2f1d9d48b.png\" width=\"1591\" \/><\/p>\n<\/p>\n<\/p>\n<h2>3. \u5173\u952e\u6280\u672f-SimAM<\/h2>\n<\/p>\n<p>\u95ee\u95eeai&#xff0c;\u4ec0\u4e48\u662f simam<\/p>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"891\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250814003438-689d2f1e0b06b.png\" width=\"1372\" \/><\/p>\n<p>SimAM&#xff1a;\u8f7b\u91cf\u7ea7\u6ce8\u610f\u529b\u673a\u5236&#xff0c;\u89e3\u9501\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u65b0\u6f5c\u529b\u3010\u539f\u7406\u8bb2\u89e3\u53ca\u4ee3\u7801&#xff01;&#xff01;&#xff01;\u3011_simam\u6ce8\u610f\u529b-CSDN\u535a\u5ba2<\/p>\n<\/p>\n<p>import torch.nn as nn<br \/>\nimport torch<\/p>\n<p>class SimAM(nn.Module):<br \/>\n    def __init__(self, lambda_param&#061;1e-5):<br \/>\n        super().__init__()<br \/>\n        self.lambda_param &#061; lambda_param<br \/>\n        self.sigmoid &#061; nn.Sigmoid()<\/p>\n<p>    def forward(self, x):<br \/>\n        b, c, h, w &#061; x.size()<br \/>\n        n &#061; h * w &#8211; 1<br \/>\n        mean &#061; torch.mean(x, dim&#061;[2,3], keepdim&#061;True)<br \/>\n        var &#061; torch.sum((x &#8211; mean)**2, dim&#061;[2,3], keepdim&#061;True) \/ n<br \/>\n        e_t &#061; (x &#8211; mean)**2 \/ (4*(var &#043; self.lambda_param)) &#043; 0.5<br \/>\n        return x * self.sigmoid(e_t)<\/p>\n<p>if __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    device &#061; torch.device(&#034;cuda&#034; if torch.cuda.is_available() else &#034;cpu&#034;)<br \/>\n    simam &#061; SimAM().to(device)<br \/>\n    input_images &#061; torch.randn(1, 3, 256, 256).to(device)<br \/>\n    output &#061; simam(input_images)<br \/>\n    print(output.shape) <\/p>\n<p>\u8fd0\u884c&#xff0c;<\/p>\n<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"121\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250814003438-689d2f1ea923a.png\" width=\"439\" \/><\/p>\n<\/p>\n<p>\u7136\u540e&#xff0c;\u6211\u4eec\u8981\u627e\u5230efficient_v2\u7684\u6e90\u7801&#xff0c;\u7528simam\u4ee3\u66ff&#xff0c;Fused-MBConv\u5c42\u4e2d\u7684SE\u6a21\u5757<\/p>\n<p>efficient_v2\u7684\u6e90\u7801&#xff1a;<\/p>\n<p>\u7ecf\u5178CNN\u6a21\u578b&#xff08;\u5341\u4e09&#xff09;&#xff1a;EfficientNetV2&#xff08;PyTorch\u8be6\u7ec6\u6ce8\u91ca\u7248&#xff09;-CSDN\u535a\u5ba2<\/p>\n<p>\u53d1\u73b0Fused-MBConv\u5e76\u6ca1\u6709\u6240\u8c13\u7684SE\u6a21\u5757<\/p>\n<p>\u4f46\u6ca1\u5173\u7cfb&#xff0c;\u76f4\u63a5\u7ed9\u4ed6\u52a0\u4e0aSimAM\u3002<\/p>\n<\/p>\n<p>\u5b8c\u6574\u4ee3\u7801<\/p>\n<p>from collections import OrderedDict<br \/>\nfrom functools import partial<br \/>\nfrom typing import Callable, Optional<\/p>\n<p>import torch.nn as nn<br \/>\nimport torch<br \/>\nfrom torch import Tensor<\/p>\n<p>#&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;SimAM&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/p>\n<p>class SimAM(nn.Module):<br \/>\n    def __init__(self, lambda_param&#061;1e-5):<br \/>\n        super().__init__()<br \/>\n        self.lambda_param &#061; lambda_param<br \/>\n        self.sigmoid &#061; nn.Sigmoid()<\/p>\n<p>    def forward(self, x):<br \/>\n        b, c, h, w &#061; x.size()<br \/>\n        n &#061; h * w &#8211; 1<br \/>\n        mean &#061; torch.mean(x, dim&#061;[2,3], keepdim&#061;True)<br \/>\n        var &#061; torch.sum((x &#8211; mean)**2, dim&#061;[2,3], keepdim&#061;True) \/ n<br \/>\n        e_t &#061; (x &#8211; mean)**2 \/ (4*(var &#043; self.lambda_param)) &#043; 0.5<br \/>\n        return x * self.sigmoid(e_t)<\/p>\n<p>#&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;efficient&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;&#061;<\/p>\n<p>def drop_path(x, drop_prob: float &#061; 0., training: bool &#061; False):<br \/>\n    &#034;&#034;&#034;<br \/>\n    Drop paths (Stochastic Depth) per sample (when applied in main path of residual blocks).<br \/>\n    &#034;Deep Networks with Stochastic Depth&#034;, https:\/\/arxiv.org\/pdf\/1603.09382.pdf<\/p>\n<p>    This function is taken from the rwightman.<br \/>\n    It can be seen here:<br \/>\n    https:\/\/github.com\/rwightman\/pytorch-image-models\/blob\/master\/timm\/models\/layers\/drop.py#L140<br \/>\n    &#034;&#034;&#034;<br \/>\n    if drop_prob &#061;&#061; 0. or not training:<br \/>\n        return x<br \/>\n    keep_prob &#061; 1 &#8211; drop_prob<br \/>\n    shape &#061; (x.shape[0],) &#043; (1,) * (x.ndim &#8211; 1)  # work with diff dim tensors, not just 2D ConvNets<br \/>\n    random_tensor &#061; keep_prob &#043; torch.rand(shape, dtype&#061;x.dtype, device&#061;x.device)<br \/>\n    random_tensor.floor_()  # binarize<br \/>\n    output &#061; x.div(keep_prob) * random_tensor<br \/>\n    return output<\/p>\n<p>class DropPath(nn.Module):<br \/>\n    &#034;&#034;&#034;<br \/>\n    Drop paths (Stochastic Depth) per sample  (when applied in main path of residual blocks).<br \/>\n    &#034;Deep Networks with Stochastic Depth&#034;, https:\/\/arxiv.org\/pdf\/1603.09382.pdf<br \/>\n    &#034;&#034;&#034;<br \/>\n    def __init__(self, drop_prob&#061;None):<br \/>\n        super(DropPath, self).__init__()<br \/>\n        self.drop_prob &#061; drop_prob<\/p>\n<p>    def forward(self, x):<br \/>\n        return drop_path(x, self.drop_prob, self.training)<\/p>\n<p>class ConvBNAct(nn.Module):<br \/>\n    def __init__(self,<br \/>\n                 in_planes: int,<br \/>\n                 out_planes: int,<br \/>\n                 kernel_size: int &#061; 3,<br \/>\n                 stride: int &#061; 1,<br \/>\n                 groups: int &#061; 1,<br \/>\n                 norm_layer: Optional[Callable[&#8230;, nn.Module]] &#061; None,<br \/>\n                 activation_layer: Optional[Callable[&#8230;, nn.Module]] &#061; None):<br \/>\n        super(ConvBNAct, self).__init__()<\/p>\n<p>        padding &#061; (kernel_size &#8211; 1) \/\/ 2<br \/>\n        if norm_layer is None:<br \/>\n            norm_layer &#061; nn.BatchNorm2d<br \/>\n        if activation_layer is None:<br \/>\n            activation_layer &#061; nn.SiLU  # alias Swish  (torch&gt;&#061;1.7)<\/p>\n<p>        self.conv &#061; nn.Conv2d(in_channels&#061;in_planes,<br \/>\n                              out_channels&#061;out_planes,<br \/>\n                              kernel_size&#061;kernel_size,<br \/>\n                              stride&#061;stride,<br \/>\n                              padding&#061;padding,<br \/>\n                              groups&#061;groups,<br \/>\n                              bias&#061;False)<\/p>\n<p>        self.bn &#061; norm_layer(out_planes)<br \/>\n        self.act &#061; activation_layer()<\/p>\n<p>    def forward(self, x):<br \/>\n        result &#061; self.conv(x)<br \/>\n        result &#061; self.bn(result)<br \/>\n        result &#061; self.act(result)<\/p>\n<p>        return result<\/p>\n<p>class SqueezeExcite(nn.Module):<br \/>\n    def __init__(self,<br \/>\n                 input_c: int,   # block input channel<br \/>\n                 expand_c: int,  # block expand channel<br \/>\n                 se_ratio: float &#061; 0.25):<br \/>\n        super(SqueezeExcite, self).__init__()<br \/>\n        squeeze_c &#061; int(input_c * se_ratio)<br \/>\n        self.conv_reduce &#061; nn.Conv2d(expand_c, squeeze_c, 1)<br \/>\n        self.act1 &#061; nn.SiLU()  # alias Swish<br \/>\n        self.conv_expand &#061; nn.Conv2d(squeeze_c, expand_c, 1)<br \/>\n        self.act2 &#061; nn.Sigmoid()<\/p>\n<p>    def forward(self, x: Tensor) -&gt; Tensor:<br \/>\n        scale &#061; x.mean((2, 3), keepdim&#061;True)<br \/>\n        scale &#061; self.conv_reduce(scale)<br \/>\n        scale &#061; self.act1(scale)<br \/>\n        scale &#061; self.conv_expand(scale)<br \/>\n        scale &#061; self.act2(scale)<br \/>\n        return scale * x<\/p>\n<p>class MBConv(nn.Module):<br \/>\n    def __init__(self,<br \/>\n                 kernel_size: int,<br \/>\n                 input_c: int,<br \/>\n                 out_c: int,<br \/>\n                 expand_ratio: int,<br \/>\n                 stride: int,<br \/>\n                 se_ratio: float,<br \/>\n                 drop_rate: float,<br \/>\n                 norm_layer: Callable[&#8230;, nn.Module]):<br \/>\n        super(MBConv, self).__init__()<\/p>\n<p>        if stride not in [1, 2]:<br \/>\n            raise ValueError(&#034;illegal stride value.&#034;)<\/p>\n<p>        self.has_shortcut &#061; (stride &#061;&#061; 1 and input_c &#061;&#061; out_c)<\/p>\n<p>        activation_layer &#061; nn.SiLU  # alias Swish<br \/>\n        expanded_c &#061; input_c * expand_ratio<\/p>\n<p>        # \u5728EfficientNetV2\u4e2d&#xff0c;MBConv\u4e2d\u4e0d\u5b58\u5728expansion&#061;1\u7684\u60c5\u51b5\u6240\u4ee5conv_pw\u80af\u5b9a\u5b58\u5728<br \/>\n        assert expand_ratio !&#061; 1<br \/>\n        # Point-wise expansion<br \/>\n        self.expand_conv &#061; ConvBNAct(input_c,<br \/>\n                                     expanded_c,<br \/>\n                                     kernel_size&#061;1,<br \/>\n                                     norm_layer&#061;norm_layer,<br \/>\n                                     activation_layer&#061;activation_layer)<\/p>\n<p>        # Depth-wise convolution<br \/>\n        self.dwconv &#061; ConvBNAct(expanded_c,<br \/>\n                                expanded_c,<br \/>\n                                kernel_size&#061;kernel_size,<br \/>\n                                stride&#061;stride,<br \/>\n                                groups&#061;expanded_c,<br \/>\n                                norm_layer&#061;norm_layer,<br \/>\n                                activation_layer&#061;activation_layer)<\/p>\n<p>        self.se &#061; SqueezeExcite(input_c, expanded_c, se_ratio) if se_ratio &gt; 0 else nn.Identity()<\/p>\n<p>        # Point-wise linear projection<br \/>\n        self.project_conv &#061; ConvBNAct(expanded_c,<br \/>\n                                      out_planes&#061;out_c,<br \/>\n                                      kernel_size&#061;1,<br \/>\n                                      norm_layer&#061;norm_layer,<br \/>\n                                      activation_layer&#061;nn.Identity)  # \u6ce8\u610f\u8fd9\u91cc\u6ca1\u6709\u6fc0\u6d3b\u51fd\u6570&#xff0c;\u6240\u6709\u4f20\u5165Identity<\/p>\n<p>        self.out_channels &#061; out_c<\/p>\n<p>        # \u53ea\u6709\u5728\u4f7f\u7528shortcut\u8fde\u63a5\u65f6\u624d\u4f7f\u7528dropout\u5c42<br \/>\n        self.drop_rate &#061; drop_rate<br \/>\n        if self.has_shortcut and drop_rate &gt; 0:<br \/>\n            self.dropout &#061; DropPath(drop_rate)<\/p>\n<p>    def forward(self, x: Tensor) -&gt; Tensor:<br \/>\n        result &#061; self.expand_conv(x)<br \/>\n        result &#061; self.dwconv(result)<br \/>\n        result &#061; self.se(result)<br \/>\n        result &#061; self.project_conv(result)<\/p>\n<p>        if self.has_shortcut:<br \/>\n            if self.drop_rate &gt; 0:<br \/>\n                result &#061; self.dropout(result)<br \/>\n            result &#043;&#061; x<\/p>\n<p>        return result<\/p>\n<p>class FusedMBConv(nn.Module):<br \/>\n    def __init__(self,<br \/>\n                 kernel_size: int,<br \/>\n                 input_c: int,<br \/>\n                 out_c: int,<br \/>\n                 expand_ratio: int,<br \/>\n                 stride: int,<br \/>\n                 se_ratio: float,<br \/>\n                 drop_rate: float,<br \/>\n                 norm_layer: Callable[&#8230;, nn.Module]):<br \/>\n        super(FusedMBConv, self).__init__()<\/p>\n<p>        assert stride in [1, 2]<br \/>\n        assert se_ratio &#061;&#061; 0<\/p>\n<p>        self.has_shortcut &#061; stride &#061;&#061; 1 and input_c &#061;&#061; out_c<br \/>\n        self.drop_rate &#061; drop_rate<br \/>\n        self.has_expansion &#061; expand_ratio !&#061; 1<br \/>\n        self.simam &#061; SimAM()  # \u65b0\u589eSimAM\u6a21\u5757<\/p>\n<p>        activation_layer &#061; nn.SiLU  # alias Swish<br \/>\n        expanded_c &#061; input_c * expand_ratio<\/p>\n<p>        # \u53ea\u6709\u5f53expand ratio\u4e0d\u7b49\u4e8e1\u65f6\u624d\u6709expand conv<br \/>\n        if self.has_expansion:<br \/>\n            # Expansion convolution<br \/>\n            self.expand_conv &#061; ConvBNAct(input_c,<br \/>\n                                         expanded_c,<br \/>\n                                         kernel_size&#061;kernel_size,<br \/>\n                                         stride&#061;stride,<br \/>\n                                         norm_layer&#061;norm_layer,<br \/>\n                                         activation_layer&#061;activation_layer)<\/p>\n<p>            self.project_conv &#061; ConvBNAct(expanded_c,<br \/>\n                                          out_c,<br \/>\n                                          kernel_size&#061;1,<br \/>\n                                          norm_layer&#061;norm_layer,<br \/>\n                                          activation_layer&#061;nn.Identity)  # \u6ce8\u610f\u6ca1\u6709\u6fc0\u6d3b\u51fd\u6570<br \/>\n        else:<br \/>\n            # \u5f53\u53ea\u6709project_conv\u65f6\u7684\u60c5\u51b5<br \/>\n            self.project_conv &#061; ConvBNAct(input_c,<br \/>\n                                          out_c,<br \/>\n                                          kernel_size&#061;kernel_size,<br \/>\n                                          stride&#061;stride,<br \/>\n                                          norm_layer&#061;norm_layer,<br \/>\n                                          activation_layer&#061;activation_layer)  # \u6ce8\u610f\u6709\u6fc0\u6d3b\u51fd\u6570<\/p>\n<p>        self.out_channels &#061; out_c<\/p>\n<p>        # \u53ea\u6709\u5728\u4f7f\u7528shortcut\u8fde\u63a5\u65f6\u624d\u4f7f\u7528dropout\u5c42<br \/>\n        self.drop_rate &#061; drop_rate<br \/>\n        if self.has_shortcut and drop_rate &gt; 0:<br \/>\n            self.dropout &#061; DropPath(drop_rate)<\/p>\n<p>    def forward(self, x: Tensor) -&gt; Tensor:<br \/>\n        if self.has_expansion:<br \/>\n            result &#061; self.expand_conv(x)<br \/>\n            result &#061; self.project_conv(result)<br \/>\n        else:<br \/>\n            result &#061; self.project_conv(x)<br \/>\n        result &#061; self.simam(result)  # \u65b0\u589e&#xff1a;\u5e94\u7528SimAM\u6ce8\u610f\u529b<br \/>\n        if self.has_shortcut:<br \/>\n            if self.drop_rate &gt; 0:<br \/>\n                result &#061; self.dropout(result)<\/p>\n<p>            result &#043;&#061; x<\/p>\n<p>        return result<\/p>\n<p>class EfficientNetV2(nn.Module):<br \/>\n    def __init__(self,<br \/>\n                 model_cnf: list,<br \/>\n                 num_classes: int &#061; 1000,<br \/>\n                 num_features: int &#061; 1280,<br \/>\n                 dropout_rate: float &#061; 0.2,<br \/>\n                 drop_connect_rate: float &#061; 0.2):<br \/>\n        super(EfficientNetV2, self).__init__()<\/p>\n<p>        for cnf in model_cnf:<br \/>\n            assert len(cnf) &#061;&#061; 8<\/p>\n<p>        norm_layer &#061; partial(nn.BatchNorm2d, eps&#061;1e-3, momentum&#061;0.1)<\/p>\n<p>        stem_filter_num &#061; model_cnf[0][4]<\/p>\n<p>        self.stem &#061; ConvBNAct(3,<br \/>\n                              stem_filter_num,<br \/>\n                              kernel_size&#061;3,<br \/>\n                              stride&#061;2,<br \/>\n                              norm_layer&#061;norm_layer)  # \u6fc0\u6d3b\u51fd\u6570\u9ed8\u8ba4\u662fSiLU<\/p>\n<p>        total_blocks &#061; sum([i[0] for i in model_cnf])<br \/>\n        block_id &#061; 0<br \/>\n        blocks &#061; []<br \/>\n        for cnf in model_cnf:<br \/>\n            repeats &#061; cnf[0]<br \/>\n            op &#061; FusedMBConv if cnf[-2] &#061;&#061; 0 else MBConv<br \/>\n            for i in range(repeats):<br \/>\n                blocks.append(op(kernel_size&#061;cnf[1],<br \/>\n                                 input_c&#061;cnf[4] if i &#061;&#061; 0 else cnf[5],<br \/>\n                                 out_c&#061;cnf[5],<br \/>\n                                 expand_ratio&#061;cnf[3],<br \/>\n                                 stride&#061;cnf[2] if i &#061;&#061; 0 else 1,<br \/>\n                                 se_ratio&#061;cnf[-1],<br \/>\n                                 drop_rate&#061;drop_connect_rate * block_id \/ total_blocks,<br \/>\n                                 norm_layer&#061;norm_layer))<br \/>\n                block_id &#043;&#061; 1<br \/>\n        self.blocks &#061; nn.Sequential(*blocks)<\/p>\n<p>        head_input_c &#061; model_cnf[-1][-3]<br \/>\n        head &#061; OrderedDict()<\/p>\n<p>        head.update({&#034;project_conv&#034;: ConvBNAct(head_input_c,<br \/>\n                                               num_features,<br \/>\n                                               kernel_size&#061;1,<br \/>\n                                               norm_layer&#061;norm_layer)})  # \u6fc0\u6d3b\u51fd\u6570\u9ed8\u8ba4\u662fSiLU<\/p>\n<p>        head.update({&#034;avgpool&#034;: nn.AdaptiveAvgPool2d(1)})<br \/>\n        head.update({&#034;flatten&#034;: nn.Flatten()})<\/p>\n<p>        if dropout_rate &gt; 0:<br \/>\n            head.update({&#034;dropout&#034;: nn.Dropout(p&#061;dropout_rate, inplace&#061;True)})<br \/>\n        head.update({&#034;classifier&#034;: nn.Linear(num_features, num_classes)})<\/p>\n<p>        self.head &#061; nn.Sequential(head)<\/p>\n<p>        # initial weights<br \/>\n        for m in self.modules():<br \/>\n            if isinstance(m, nn.Conv2d):<br \/>\n                nn.init.kaiming_normal_(m.weight, mode&#061;&#034;fan_out&#034;)<br \/>\n                if m.bias is not None:<br \/>\n                    nn.init.zeros_(m.bias)<br \/>\n            elif isinstance(m, nn.BatchNorm2d):<br \/>\n                nn.init.ones_(m.weight)<br \/>\n                nn.init.zeros_(m.bias)<br \/>\n            elif isinstance(m, nn.Linear):<br \/>\n                nn.init.normal_(m.weight, 0, 0.01)<br \/>\n                nn.init.zeros_(m.bias)<\/p>\n<p>    def forward(self, x: Tensor) -&gt; Tensor:<br \/>\n        x &#061; self.stem(x)<br \/>\n        x &#061; self.blocks(x)<br \/>\n        x &#061; self.head(x)<\/p>\n<p>        return x<\/p>\n<p>def efficientnetv2_s(num_classes: int &#061; 1000):<br \/>\n    &#034;&#034;&#034;<br \/>\n    EfficientNetV2<br \/>\n    https:\/\/arxiv.org\/abs\/2104.00298<br \/>\n    &#034;&#034;&#034;<br \/>\n    # train_size: 300, eval_size: 384<\/p>\n<p>    # repeat, kernel, stride, expansion, in_c, out_c, operator, se_ratio<br \/>\n    model_config &#061; [[2, 3, 1, 1, 24, 24, 0, 0],<br \/>\n                    [4, 3, 2, 4, 24, 48, 0, 0],<br \/>\n                    [4, 3, 2, 4, 48, 64, 0, 0],<br \/>\n                    [6, 3, 2, 4, 64, 128, 1, 0.25],<br \/>\n                    [9, 3, 1, 6, 128, 160, 1, 0.25],<br \/>\n                    [15, 3, 2, 6, 160, 256, 1, 0.25]]<\/p>\n<p>    model &#061; EfficientNetV2(model_cnf&#061;model_config,<br \/>\n                           num_classes&#061;num_classes,<br \/>\n                           dropout_rate&#061;0.2)<br \/>\n    return model<\/p>\n<p>def efficientnetv2_m(num_classes: int &#061; 1000):<br \/>\n    &#034;&#034;&#034;<br \/>\n    EfficientNetV2<br \/>\n    https:\/\/arxiv.org\/abs\/2104.00298<br \/>\n    &#034;&#034;&#034;<br \/>\n    # train_size: 384, eval_size: 480<\/p>\n<p>    # repeat, kernel, stride, expansion, in_c, out_c, operator, se_ratio<br \/>\n    model_config &#061; [[3, 3, 1, 1, 24, 24, 0, 0],<br \/>\n                    [5, 3, 2, 4, 24, 48, 0, 0],<br \/>\n                    [5, 3, 2, 4, 48, 80, 0, 0],<br \/>\n                    [7, 3, 2, 4, 80, 160, 1, 0.25],<br \/>\n                    [14, 3, 1, 6, 160, 176, 1, 0.25],<br \/>\n                    [18, 3, 2, 6, 176, 304, 1, 0.25],<br \/>\n                    [5, 3, 1, 6, 304, 512, 1, 0.25]]<\/p>\n<p>    model &#061; EfficientNetV2(model_cnf&#061;model_config,<br \/>\n                           num_classes&#061;num_classes,<br \/>\n                           dropout_rate&#061;0.3)<br \/>\n    return model<\/p>\n<p>def efficientnetv2_l(num_classes: int &#061; 1000):<br \/>\n    &#034;&#034;&#034;<br \/>\n    EfficientNetV2<br \/>\n    https:\/\/arxiv.org\/abs\/2104.00298<br \/>\n    &#034;&#034;&#034;<br \/>\n    # train_size: 384, eval_size: 480<\/p>\n<p>    # repeat, kernel, stride, expansion, in_c, out_c, operator, se_ratio<br \/>\n    model_config &#061; [[4, 3, 1, 1, 32, 32, 0, 0],<br \/>\n                    [7, 3, 2, 4, 32, 64, 0, 0],<br \/>\n                    [7, 3, 2, 4, 64, 96, 0, 0],<br \/>\n                    [10, 3, 2, 4, 96, 192, 1, 0.25],<br \/>\n                    [19, 3, 1, 6, 192, 224, 1, 0.25],<br \/>\n                    [25, 3, 2, 6, 224, 384, 1, 0.25],<br \/>\n                    [7, 3, 1, 6, 384, 640, 1, 0.25]]<\/p>\n<p>    model &#061; EfficientNetV2(model_cnf&#061;model_config,<br \/>\n                           num_classes&#061;num_classes,<br \/>\n                           dropout_rate&#061;0.4)<br \/>\n    return model<\/p>\n<p>if __name__ &#061;&#061; &#034;__main__&#034;:<br \/>\n    device &#061; torch.device(&#034;cuda&#034; if torch.cuda.is_available() else &#034;cpu&#034;)<br \/>\n    simam &#061; efficientnetv2_m(num_classes &#061; 5).to(device)<br \/>\n    input_images &#061; torch.randn(1, 3, 256, 256).to(device)<br \/>\n    output &#061; simam(input_images)<br \/>\n    print(output.shape) <\/p>\n<p>\u8fd0\u884c\u540e  <img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"114\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250814003438-689d2f1ec9f92.png\" width=\"322\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb690\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf21\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u590d\u73b0\u57fa\u4e8eEfficientNet-ViT\u96c6\u6210\u6a21\u578b\u7684\u773c\u5e95\u56fe\u50cf\u5206\u7c7b\u65b9\u6cd5\u3002\u91cd\u70b9\u5185\u5bb9\u5305\u62ec\uff1a1\uff09\u4f7f\u7528\u52a0\u6743\u8f6f\u6295\u7968\u6cd5\uff080.6\u548c0.4\u7684\u6743\u91cd\uff09\u878d\u5408EfficientNetV2\u548cViT\u6a21\u578b\u7684\u9884\u6d4b\u7ed3\u679c\uff1b2\uff09\u5728EfficientNetV2\u4e2d\u5f15\u5165SimAM\u65e0\u53c2\u6570\u6ce8\u610f\u529b\u6a21\u5757\u8fdb\u884c\u6539\u8fdb\u3002\u6587\u7ae0\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684PyTorch\u5b9e\u73b0\u4ee3\u7801\uff0c\u5305\u62ec\u6a21\u578b\u96c6\u6210\u3001\u6982\u7387\u52a0\u6743\u8ba1\u7b97\u4ee5\u53caSimAM\u6a21\u5757\u7684\u96c6\u6210\u65b9\u6cd5\uff0c\u5e76\u5c55\u793a\u4e86\u5982\u4f55\u4fee\u6539\u6a21\u578b\u8f93\u51fa\u7c7b\u522b\u6570\u3002\u8be5\u590d\u73b0\u65b9\u6cd5\u9002\u7528\u4e8e\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\uff0c\u901a\u8fc7\u4e24\u79cd\u4e0d\u540c\u7ed3\u6784\u7684\u6a21\u578b\u96c6\u6210\u63d0\u5347\u5206\u7c7b\u6027\u80fd\u3002<\/p>\n","protected":false},"author":2,"featured_media":55785,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[2394,5758],"topic":[],"class_list":["post-55793","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-cnn","tag-efficient"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u624b\u628a\u624b\u6559\u4f60\u5982\u4f55\u590d\u73b0\u522b\u4eba\u7684\u8bba\u6587\uff08CNN\u76f8\u5173\uff09\uff08\u4f8b\uff1a\u57fa\u4e8e\u96c6\u6210\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u548c Vit \u7684\u773c\u5e95\u56fe\u50cf\u5206\u7c7b\u7814\u7a76\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/55793.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u624b\u628a\u624b\u6559\u4f60\u5982\u4f55\u590d\u73b0\u522b\u4eba\u7684\u8bba\u6587\uff08CNN\u76f8\u5173\uff09\uff08\u4f8b\uff1a\u57fa\u4e8e\u96c6\u6210\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u548c Vit \u7684\u773c\u5e95\u56fe\u50cf\u5206\u7c7b\u7814\u7a76\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb690\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf21\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u590d\u73b0\u57fa\u4e8eEfficientNet-ViT\u96c6\u6210\u6a21\u578b\u7684\u773c\u5e95\u56fe\u50cf\u5206\u7c7b\u65b9\u6cd5\u3002\u91cd\u70b9\u5185\u5bb9\u5305\u62ec\uff1a1\uff09\u4f7f\u7528\u52a0\u6743\u8f6f\u6295\u7968\u6cd5\uff080.6\u548c0.4\u7684\u6743\u91cd\uff09\u878d\u5408EfficientNetV2\u548cViT\u6a21\u578b\u7684\u9884\u6d4b\u7ed3\u679c\uff1b2\uff09\u5728EfficientNetV2\u4e2d\u5f15\u5165SimAM\u65e0\u53c2\u6570\u6ce8\u610f\u529b\u6a21\u5757\u8fdb\u884c\u6539\u8fdb\u3002\u6587\u7ae0\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684PyTorch\u5b9e\u73b0\u4ee3\u7801\uff0c\u5305\u62ec\u6a21\u578b\u96c6\u6210\u3001\u6982\u7387\u52a0\u6743\u8ba1\u7b97\u4ee5\u53caSimAM\u6a21\u5757\u7684\u96c6\u6210\u65b9\u6cd5\uff0c\u5e76\u5c55\u793a\u4e86\u5982\u4f55\u4fee\u6539\u6a21\u578b\u8f93\u51fa\u7c7b\u522b\u6570\u3002\u8be5\u590d\u73b0\u65b9\u6cd5\u9002\u7528\u4e8e\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\uff0c\u901a\u8fc7\u4e24\u79cd\u4e0d\u540c\u7ed3\u6784\u7684\u6a21\u578b\u96c6\u6210\u63d0\u5347\u5206\u7c7b\u6027\u80fd\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/55793.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-14T00:34:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250814003436-689d2f1cd8585.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"10 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/55793.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/55793.html\",\"name\":\"\u624b\u628a\u624b\u6559\u4f60\u5982\u4f55\u590d\u73b0\u522b\u4eba\u7684\u8bba\u6587\uff08CNN\u76f8\u5173\uff09\uff08\u4f8b\uff1a\u57fa\u4e8e\u96c6\u6210\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u548c Vit \u7684\u773c\u5e95\u56fe\u50cf\u5206\u7c7b\u7814\u7a76\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-14T00:34:39+00:00\",\"dateModified\":\"2025-08-14T00:34:39+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/55793.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/55793.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/55793.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u624b\u628a\u624b\u6559\u4f60\u5982\u4f55\u590d\u73b0\u522b\u4eba\u7684\u8bba\u6587\uff08CNN\u76f8\u5173\uff09\uff08\u4f8b\uff1a\u57fa\u4e8e\u96c6\u6210\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u548c Vit \u7684\u773c\u5e95\u56fe\u50cf\u5206\u7c7b\u7814\u7a76\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u624b\u628a\u624b\u6559\u4f60\u5982\u4f55\u590d\u73b0\u522b\u4eba\u7684\u8bba\u6587\uff08CNN\u76f8\u5173\uff09\uff08\u4f8b\uff1a\u57fa\u4e8e\u96c6\u6210\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u548c Vit \u7684\u773c\u5e95\u56fe\u50cf\u5206\u7c7b\u7814\u7a76\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/55793.html","og_locale":"zh_CN","og_type":"article","og_title":"\u624b\u628a\u624b\u6559\u4f60\u5982\u4f55\u590d\u73b0\u522b\u4eba\u7684\u8bba\u6587\uff08CNN\u76f8\u5173\uff09\uff08\u4f8b\uff1a\u57fa\u4e8e\u96c6\u6210\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u548c Vit \u7684\u773c\u5e95\u56fe\u50cf\u5206\u7c7b\u7814\u7a76\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb690\u6b21\uff0c\u70b9\u8d5e11\u6b21\uff0c\u6536\u85cf21\u6b21\u3002\u672c\u6587\u8be6\u7ec6\u4ecb\u7ecd\u4e86\u5982\u4f55\u590d\u73b0\u57fa\u4e8eEfficientNet-ViT\u96c6\u6210\u6a21\u578b\u7684\u773c\u5e95\u56fe\u50cf\u5206\u7c7b\u65b9\u6cd5\u3002\u91cd\u70b9\u5185\u5bb9\u5305\u62ec\uff1a1\uff09\u4f7f\u7528\u52a0\u6743\u8f6f\u6295\u7968\u6cd5\uff080.6\u548c0.4\u7684\u6743\u91cd\uff09\u878d\u5408EfficientNetV2\u548cViT\u6a21\u578b\u7684\u9884\u6d4b\u7ed3\u679c\uff1b2\uff09\u5728EfficientNetV2\u4e2d\u5f15\u5165SimAM\u65e0\u53c2\u6570\u6ce8\u610f\u529b\u6a21\u5757\u8fdb\u884c\u6539\u8fdb\u3002\u6587\u7ae0\u63d0\u4f9b\u4e86\u5b8c\u6574\u7684PyTorch\u5b9e\u73b0\u4ee3\u7801\uff0c\u5305\u62ec\u6a21\u578b\u96c6\u6210\u3001\u6982\u7387\u52a0\u6743\u8ba1\u7b97\u4ee5\u53caSimAM\u6a21\u5757\u7684\u96c6\u6210\u65b9\u6cd5\uff0c\u5e76\u5c55\u793a\u4e86\u5982\u4f55\u4fee\u6539\u6a21\u578b\u8f93\u51fa\u7c7b\u522b\u6570\u3002\u8be5\u590d\u73b0\u65b9\u6cd5\u9002\u7528\u4e8e\u56fe\u50cf\u5206\u7c7b\u4efb\u52a1\uff0c\u901a\u8fc7\u4e24\u79cd\u4e0d\u540c\u7ed3\u6784\u7684\u6a21\u578b\u96c6\u6210\u63d0\u5347\u5206\u7c7b\u6027\u80fd\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/55793.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-14T00:34:39+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250814003436-689d2f1cd8585.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"10 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/55793.html","url":"https:\/\/www.wsisp.com\/helps\/55793.html","name":"\u624b\u628a\u624b\u6559\u4f60\u5982\u4f55\u590d\u73b0\u522b\u4eba\u7684\u8bba\u6587\uff08CNN\u76f8\u5173\uff09\uff08\u4f8b\uff1a\u57fa\u4e8e\u96c6\u6210\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u548c Vit \u7684\u773c\u5e95\u56fe\u50cf\u5206\u7c7b\u7814\u7a76\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-14T00:34:39+00:00","dateModified":"2025-08-14T00:34:39+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/55793.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/55793.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/55793.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u624b\u628a\u624b\u6559\u4f60\u5982\u4f55\u590d\u73b0\u522b\u4eba\u7684\u8bba\u6587\uff08CNN\u76f8\u5173\uff09\uff08\u4f8b\uff1a\u57fa\u4e8e\u96c6\u6210\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u548c Vit \u7684\u773c\u5e95\u56fe\u50cf\u5206\u7c7b\u7814\u7a76\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/55793","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=55793"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/55793\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/55785"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=55793"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=55793"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=55793"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=55793"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}