{"id":51764,"date":"2025-08-11T06:34:52","date_gmt":"2025-08-10T22:34:52","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/51764.html"},"modified":"2025-08-11T06:34:52","modified_gmt":"2025-08-10T22:34:52","slug":"%e3%80%90%e5%ae%8c%e6%95%b4%e6%ba%90%e7%a0%81%e6%95%b0%e6%8d%ae%e9%9b%86%e9%83%a8%e7%bd%b2%e6%95%99%e7%a8%8b%e3%80%91%e7%94%b5%e6%b0%94%e8%ae%be%e5%a4%87%e9%83%a8%e4%bb%b6%e8%af%86%e5%88%ab%e7%b3%bb","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/51764.html","title":{"rendered":"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u8bc6\u522b\u7cfb\u7edf\u6e90\u7801\u548c\u6570\u636e\u96c6\uff1a\u6539\u8fdbyolo11-RevCol"},"content":{"rendered":"<h2>\u80cc\u666f\u610f\u4e49<\/h2>\n<p>\u7814\u7a76\u80cc\u666f\u4e0e\u610f\u4e49<\/p>\n<p>\u5728\u73b0\u4ee3\u7535\u6c14\u8bbe\u5907\u7684\u8bbe\u8ba1\u4e0e\u7ef4\u62a4\u4e2d&#xff0c;\u90e8\u4ef6\u7684\u51c6\u786e\u8bc6\u522b\u4e0e\u5206\u7c7b\u662f\u786e\u4fdd\u7cfb\u7edf\u5b89\u5168\u6027\u548c\u53ef\u9760\u6027\u7684\u5173\u952e\u73af\u8282\u3002\u968f\u7740\u7535\u6c14\u8bbe\u5907\u7684\u590d\u6742\u6027\u4e0d\u65ad\u589e\u52a0&#xff0c;\u4f20\u7edf\u7684\u4eba\u5de5\u8bc6\u522b\u65b9\u6cd5\u5df2\u96be\u4ee5\u6ee1\u8db3\u9ad8\u6548\u6027\u548c\u51c6\u786e\u6027\u7684\u8981\u6c42\u3002\u56e0\u6b64&#xff0c;\u57fa\u4e8e\u6df1\u5ea6\u5b66\u4e60\u7684\u8ba1\u7b97\u673a\u89c6\u89c9\u6280\u672f\u9010\u6e10\u6210\u4e3a\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\u7684\u91cd\u8981\u624b\u6bb5\u3002YOLO&#xff08;You Only Look Once&#xff09;\u7cfb\u5217\u6a21\u578b\u56e0\u5176\u5b9e\u65f6\u6027\u548c\u9ad8\u7cbe\u5ea6\u7684\u7279\u70b9&#xff0c;\u5df2\u5e7f\u6cdb\u5e94\u7528\u4e8e\u76ee\u6807\u68c0\u6d4b\u548c\u8bc6\u522b\u4efb\u52a1\u4e2d\u3002\u5c24\u5176\u662fYOLOv11\u7684\u6539\u8fdb\u7248\u672c&#xff0c;\u51ed\u501f\u5176\u5728\u7279\u5f81\u63d0\u53d6\u548c\u5904\u7406\u901f\u5ea6\u4e0a\u7684\u4f18\u52bf&#xff0c;\u4e3a\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u7684\u81ea\u52a8\u8bc6\u522b\u63d0\u4f9b\u4e86\u65b0\u7684\u53ef\u80fd\u6027\u3002<\/p>\n<p>\u672c\u7814\u7a76\u65e8\u5728\u57fa\u4e8e\u6539\u8fdb\u7684YOLOv11\u6a21\u578b&#xff0c;\u6784\u5efa\u4e00\u4e2a\u9ad8\u6548\u7684\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u8bc6\u522b\u7cfb\u7edf\u3002\u8be5\u7cfb\u7edf\u5c06\u5229\u7528\u4e00\u4e2a\u5305\u542b1162\u5f20\u56fe\u50cf\u7684\u6570\u636e\u96c6&#xff0c;\u6db5\u76d6\u4e86\u516b\u7c7b\u7535\u6c14\u90e8\u4ef6&#xff0c;\u5305\u62ecBushing\u3001Disc\u3001Disc-Pin\u3001Isolating\u3001La\u3001Others\u3001Pin\u548cwall\u7b49\u3002\u8fd9\u4e9b\u90e8\u4ef6\u5728\u7535\u6c14\u8bbe\u5907\u7684\u8fd0\u884c\u4e2d\u626e\u6f14\u7740\u91cd\u8981\u89d2\u8272&#xff0c;\u51c6\u786e\u8bc6\u522b\u5b83\u4eec\u4e0d\u4ec5\u6709\u52a9\u4e8e\u8bbe\u5907\u7684\u6545\u969c\u8bca\u65ad\u548c\u7ef4\u62a4&#xff0c;\u8fd8\u80fd\u4e3a\u8bbe\u5907\u7684\u8bbe\u8ba1\u4f18\u5316\u63d0\u4f9b\u6570\u636e\u652f\u6301\u3002<\/p>\n<p>\u901a\u8fc7\u5bf9\u6570\u636e\u96c6\u7684\u6df1\u5165\u5206\u6790\u4e0e\u5904\u7406&#xff0c;\u7814\u7a76\u5c06\u91c7\u7528\u5b9e\u4f8b\u5206\u5272\u6280\u672f&#xff0c;\u4ee5\u5b9e\u73b0\u5bf9\u7535\u6c14\u90e8\u4ef6\u7684\u7cbe\u786e\u5b9a\u4f4d\u548c\u5206\u7c7b\u3002\u6570\u636e\u96c6\u4e2d\u7684\u56fe\u50cf\u7ecf\u8fc7\u9884\u5904\u7406&#xff0c;\u786e\u4fdd\u4e86\u5728\u4e0d\u540c\u73af\u5883\u6761\u4ef6\u4e0b\u7684\u9c81\u68d2\u6027\u3002\u5c3d\u7ba1\u672a\u91c7\u7528\u56fe\u50cf\u589e\u5f3a\u6280\u672f&#xff0c;\u4f46\u901a\u8fc7\u9ad8\u5206\u8fa8\u7387\u7684\u56fe\u50cf\u8f93\u5165&#xff0c;\u7cfb\u7edf\u4ecd\u80fd\u6709\u6548\u63d0\u53d6\u51fa\u5173\u952e\u7279\u5f81&#xff0c;\u63d0\u5347\u8bc6\u522b\u7684\u51c6\u786e\u6027\u3002<\/p>\n<p>\u672c\u7814\u7a76\u7684\u610f\u4e49\u5728\u4e8e\u63a8\u52a8\u7535\u6c14\u8bbe\u5907\u667a\u80fd\u5316\u7ba1\u7406\u7684\u53d1\u5c55&#xff0c;\u63d0\u5347\u8bbe\u5907\u7ef4\u62a4\u7684\u6548\u7387\u4e0e\u5b89\u5168\u6027\u3002\u901a\u8fc7\u6784\u5efa\u57fa\u4e8eYOLOv11\u7684\u8bc6\u522b\u7cfb\u7edf&#xff0c;\u80fd\u591f\u4e3a\u7535\u6c14\u884c\u4e1a\u63d0\u4f9b\u4e00\u79cd\u65b0\u578b\u7684\u667a\u80fd\u89e3\u51b3\u65b9\u6848&#xff0c;\u52a9\u529b\u4e8e\u5b9e\u73b0\u66f4\u9ad8\u6c34\u5e73\u7684\u81ea\u52a8\u5316\u4e0e\u667a\u80fd\u5316\u7ba1\u7406\u3002<\/p>\n<h2>\u56fe\u7247\u6548\u679c<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810223447-68991e870ae8c.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810223447-68991e879d1d7.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810223448-68991e8839585.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>\u6570\u636e\u96c6\u4fe1\u606f<\/h2>\n<p>\u672c\u9879\u76ee\u6570\u636e\u96c6\u4fe1\u606f\u4ecb\u7ecd<\/p>\n<p>\u672c\u9879\u76ee\u65e8\u5728\u6539\u8fdbYOLOv11\u6a21\u578b\u5728\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u8bc6\u522b\u7cfb\u7edf\u4e2d\u7684\u5e94\u7528&#xff0c;\u6240\u4f7f\u7528\u7684\u6570\u636e\u96c6\u56f4\u7ed5\u201cObject_identification_Isolating\u201d\u4e3b\u9898\u6784\u5efa&#xff0c;\u4e13\u6ce8\u4e8e\u7535\u6c14\u8bbe\u5907\u4e2d\u7684\u5173\u952e\u90e8\u4ef6\u8bc6\u522b\u3002\u8be5\u6570\u636e\u96c6\u5305\u542b8\u4e2a\u7c7b\u522b&#xff0c;\u5206\u522b\u4e3a&#xff1a;Bushing\u3001Disc\u3001Disc-Pin\u3001Isolating\u3001La\u3001Others\u3001Pin\u548cwall\u3002\u8fd9\u4e9b\u7c7b\u522b\u6db5\u76d6\u4e86\u7535\u6c14\u8bbe\u5907\u4e2d\u5e38\u89c1\u7684\u90e8\u4ef6&#xff0c;\u80fd\u591f\u4e3a\u6a21\u578b\u63d0\u4f9b\u4e30\u5bcc\u7684\u8bad\u7ec3\u6837\u672c&#xff0c;\u4ee5\u63d0\u9ad8\u5176\u8bc6\u522b\u7cbe\u5ea6\u548c\u6548\u7387\u3002<\/p>\n<p>\u5728\u6570\u636e\u96c6\u7684\u6784\u5efa\u8fc7\u7a0b\u4e2d&#xff0c;\u6211\u4eec\u7279\u522b\u6ce8\u91cd\u6837\u672c\u7684\u591a\u6837\u6027\u548c\u4ee3\u8868\u6027&#xff0c;\u4ee5\u786e\u4fdd\u6a21\u578b\u80fd\u591f\u5728\u5404\u79cd\u73af\u5883\u548c\u6761\u4ef6\u4e0b\u8fdb\u884c\u6709\u6548\u8bc6\u522b\u3002\u6bcf\u4e2a\u7c7b\u522b\u7684\u6837\u672c\u5747\u7ecf\u8fc7\u7cbe\u5fc3\u6311\u9009&#xff0c;\u6db5\u76d6\u4e86\u4e0d\u540c\u7684\u89c6\u89d2\u3001\u5149\u7167\u6761\u4ef6\u548c\u80cc\u666f&#xff0c;\u4ece\u800c\u589e\u5f3a\u6a21\u578b\u7684\u6cdb\u5316\u80fd\u529b\u3002\u4f8b\u5982&#xff0c;Bushing\u548cPin\u7c7b\u6837\u672c\u5c55\u793a\u4e86\u4e0d\u540c\u7c7b\u578b\u548c\u5c3a\u5bf8\u7684\u7edd\u7f18\u5b50\u548c\u8fde\u63a5\u4ef6&#xff0c;\u800cDisc\u548cDisc-Pin\u7c7b\u5219\u63d0\u4f9b\u4e86\u591a\u79cd\u5f62\u72b6\u548c\u6750\u6599\u7684\u7535\u6c14\u63a5\u89e6\u90e8\u4ef6\u3002\u8fd9\u79cd\u591a\u6837\u6027\u4e0d\u4ec5\u63d0\u5347\u4e86\u6a21\u578b\u7684\u8bad\u7ec3\u6548\u679c&#xff0c;\u4e5f\u4e3a\u540e\u7eed\u7684\u5b9e\u9645\u5e94\u7528\u5960\u5b9a\u4e86\u575a\u5b9e\u7684\u57fa\u7840\u3002<\/p>\n<p>\u6b64\u5916&#xff0c;\u6570\u636e\u96c6\u4e2d\u7684\u201cIsolating\u201d\u7c7b\u522b\u4e13\u95e8\u9488\u5bf9\u7535\u6c14\u8bbe\u5907\u4e2d\u9694\u79bb\u90e8\u4ef6\u7684\u8bc6\u522b&#xff0c;\u5177\u6709\u91cd\u8981\u7684\u5b9e\u7528\u4ef7\u503c\u3002\u901a\u8fc7\u5bf9\u8be5\u7c7b\u522b\u7684\u6df1\u5165\u5b66\u4e60&#xff0c;\u6a21\u578b\u80fd\u591f\u66f4\u51c6\u786e\u5730\u8bc6\u522b\u548c\u5206\u7c7b\u9694\u79bb\u88c5\u7f6e&#xff0c;\u4ece\u800c\u5728\u7535\u6c14\u5b89\u5168\u548c\u7ef4\u62a4\u4e2d\u53d1\u6325\u66f4\u5927\u4f5c\u7528\u3002\u603b\u4e4b&#xff0c;\u672c\u9879\u76ee\u7684\u6570\u636e\u96c6\u4e3a\u6539\u8fdbYOLOv11\u6a21\u578b\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u8bad\u7ec3\u7d20\u6750&#xff0c;\u65e8\u5728\u63d0\u5347\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u7684\u81ea\u52a8\u8bc6\u522b\u80fd\u529b&#xff0c;\u63a8\u52a8\u667a\u80fd\u7535\u6c14\u8bbe\u5907\u7684\u8fdb\u4e00\u6b65\u53d1\u5c55\u4e0e\u5e94\u7528\u3002<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810223448-68991e88d7e60.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810223449-68991e89662ee.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810223449-68991e89e6682.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810223450-68991e8a6ca55.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810223450-68991e8ad8eb9.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>\u6838\u5fc3\u4ee3\u7801<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4ee3\u7801\u4e2d\u6700\u6838\u5fc3\u7684\u90e8\u5206&#xff0c;\u5e76\u9644\u4e0a\u8be6\u7ec6\u7684\u4e2d\u6587\u6ce8\u91ca&#xff1a;<\/p>\n<p>import math<br \/>\nimport torch<br \/>\nimport torch.nn as nn<\/p>\n<p>def autopad(k, p&#061;None, d&#061;1):  # kernel, padding, dilation<br \/>\n\u201c\u201d\u201c\u81ea\u52a8\u586b\u5145\u4ee5\u786e\u4fdd\u8f93\u51fa\u5f62\u72b6\u4e0e\u8f93\u5165\u5f62\u72b6\u76f8\u540c\u3002\u201d\u201c\u201d<br \/>\nif d &gt; 1:<br \/>\n# \u8ba1\u7b97\u5b9e\u9645\u7684\u5377\u79ef\u6838\u5927\u5c0f<br \/>\nk &#061; d * (k &#8211; 1) &#043; 1 if isinstance(k, int) else [d * (x &#8211; 1) &#043; 1 for x in k]<br \/>\nif p is None:<br \/>\n# \u5982\u679c\u6ca1\u6709\u63d0\u4f9b\u586b\u5145&#xff0c;\u5219\u81ea\u52a8\u8ba1\u7b97\u586b\u5145<br \/>\np &#061; k \/\/ 2 if isinstance(k, int) else [x \/\/ 2 for x in k]<br \/>\nreturn p<\/p>\n<p>class Conv(nn.Module):<br \/>\n\u201c\u201d\u201c\u6807\u51c6\u5377\u79ef\u5c42&#xff0c;\u5305\u542b\u5377\u79ef\u3001\u6279\u5f52\u4e00\u5316\u548c\u6fc0\u6d3b\u51fd\u6570\u3002\u201d\u201c\u201d<\/p>\n<p>default_act &#061; nn.SiLU()  # \u9ed8\u8ba4\u6fc0\u6d3b\u51fd\u6570<\/p>\n<p>def __init__(self, c1, c2, k&#061;1, s&#061;1, p&#061;None, g&#061;1, d&#061;1, act&#061;True):<br \/>\n    &#034;&#034;&#034;\u521d\u59cb\u5316\u5377\u79ef\u5c42&#xff0c;\u53c2\u6570\u5305\u62ec\u8f93\u5165\u901a\u9053\u6570\u3001\u8f93\u51fa\u901a\u9053\u6570\u3001\u5377\u79ef\u6838\u5927\u5c0f\u3001\u6b65\u5e45\u3001\u586b\u5145\u3001\u5206\u7ec4\u3001\u6269\u5f20\u548c\u6fc0\u6d3b\u51fd\u6570\u3002&#034;&#034;&#034;<br \/>\n    super().__init__()<br \/>\n    # \u5b9a\u4e49\u5377\u79ef\u5c42<br \/>\n    self.conv &#061; nn.Conv2d(c1, c2, k, s, autopad(k, p, d), groups&#061;g, dilation&#061;d, bias&#061;False)<br \/>\n    # \u5b9a\u4e49\u6279\u5f52\u4e00\u5316\u5c42<br \/>\n    self.bn &#061; nn.BatchNorm2d(c2)<br \/>\n    # \u6839\u636e\u8f93\u5165\u53c2\u6570\u9009\u62e9\u6fc0\u6d3b\u51fd\u6570<br \/>\n    self.act &#061; self.default_act if act is True else act if isinstance(act, nn.Module) else nn.Identity()<\/p>\n<p>def forward(self, x):<br \/>\n    &#034;&#034;&#034;\u524d\u5411\u4f20\u64ad&#xff1a;\u5e94\u7528\u5377\u79ef\u3001\u6279\u5f52\u4e00\u5316\u548c\u6fc0\u6d3b\u51fd\u6570\u3002&#034;&#034;&#034;<br \/>\n    return self.act(self.bn(self.conv(x)))<\/p>\n<p>class DWConv(Conv):<br \/>\n\u201c\u201d\u201c\u6df1\u5ea6\u53ef\u5206\u79bb\u5377\u79ef&#xff0c;\u4f7f\u7528\u6df1\u5ea6\u5377\u79ef\u3002\u201d\u201c\u201d<\/p>\n<p>def __init__(self, c1, c2, k&#061;1, s&#061;1, d&#061;1, act&#061;True):<br \/>\n    &#034;&#034;&#034;\u521d\u59cb\u5316\u6df1\u5ea6\u5377\u79ef&#xff0c;\u53c2\u6570\u5305\u62ec\u8f93\u5165\u901a\u9053\u6570\u3001\u8f93\u51fa\u901a\u9053\u6570\u3001\u5377\u79ef\u6838\u5927\u5c0f\u3001\u6b65\u5e45\u3001\u6269\u5f20\u548c\u6fc0\u6d3b\u51fd\u6570\u3002&#034;&#034;&#034;<br \/>\n    super().__init__(c1, c2, k, s, g&#061;math.gcd(c1, c2), d&#061;d, act&#061;act)<\/p>\n<p>class DSConv(nn.Module):<br \/>\n\u201c\u201d\u201c\u6df1\u5ea6\u53ef\u5206\u79bb\u5377\u79ef\u6a21\u5757\u3002\u201d\u201c\u201d<\/p>\n<p>def __init__(self, c1, c2, k&#061;1, s&#061;1, d&#061;1, act&#061;True) -&gt; None:<br \/>\n    &#034;&#034;&#034;\u521d\u59cb\u5316\u6df1\u5ea6\u53ef\u5206\u79bb\u5377\u79ef\u6a21\u5757&#xff0c;\u5305\u542b\u6df1\u5ea6\u5377\u79ef\u548c\u9010\u70b9\u5377\u79ef\u3002&#034;&#034;&#034;<br \/>\n    super().__init__()<br \/>\n    self.dwconv &#061; DWConv(c1, c1, 3)  # \u6df1\u5ea6\u5377\u79ef<br \/>\n    self.pwconv &#061; Conv(c1, c2, 1)     # \u9010\u70b9\u5377\u79ef<\/p>\n<p>def forward(self, x):<br \/>\n    &#034;&#034;&#034;\u524d\u5411\u4f20\u64ad&#xff1a;\u5148\u901a\u8fc7\u6df1\u5ea6\u5377\u79ef&#xff0c;\u518d\u901a\u8fc7\u9010\u70b9\u5377\u79ef\u3002&#034;&#034;&#034;<br \/>\n    return self.pwconv(self.dwconv(x))<\/p>\n<p>class ConvTranspose(nn.Module):<br \/>\n\u201c\u201d\u201c\u8f6c\u7f6e\u5377\u79ef\u5c42\u3002\u201d\u201c\u201d<\/p>\n<p>default_act &#061; nn.SiLU()  # \u9ed8\u8ba4\u6fc0\u6d3b\u51fd\u6570<\/p>\n<p>def __init__(self, c1, c2, k&#061;2, s&#061;2, p&#061;0, bn&#061;True, act&#061;True):<br \/>\n    &#034;&#034;&#034;\u521d\u59cb\u5316\u8f6c\u7f6e\u5377\u79ef\u5c42&#xff0c;\u53c2\u6570\u5305\u62ec\u8f93\u5165\u901a\u9053\u6570\u3001\u8f93\u51fa\u901a\u9053\u6570\u3001\u5377\u79ef\u6838\u5927\u5c0f\u3001\u6b65\u5e45\u3001\u586b\u5145\u3001\u662f\u5426\u4f7f\u7528\u6279\u5f52\u4e00\u5316\u548c\u6fc0\u6d3b\u51fd\u6570\u3002&#034;&#034;&#034;<br \/>\n    super().__init__()<br \/>\n    self.conv_transpose &#061; nn.ConvTranspose2d(c1, c2, k, s, p, bias&#061;not bn)<br \/>\n    self.bn &#061; nn.BatchNorm2d(c2) if bn else nn.Identity()<br \/>\n    self.act &#061; self.default_act if act is True else act if isinstance(act, nn.Module) else nn.Identity()<\/p>\n<p>def forward(self, x):<br \/>\n    &#034;&#034;&#034;\u524d\u5411\u4f20\u64ad&#xff1a;\u5e94\u7528\u8f6c\u7f6e\u5377\u79ef\u3001\u6279\u5f52\u4e00\u5316\u548c\u6fc0\u6d3b\u51fd\u6570\u3002&#034;&#034;&#034;<br \/>\n    return self.act(self.bn(self.conv_transpose(x)))<\/p>\n<p>class ChannelAttention(nn.Module):<br \/>\n\u201c\u201d\u201c\u901a\u9053\u6ce8\u610f\u529b\u6a21\u5757\u3002\u201d\u201c\u201d<\/p>\n<p>def __init__(self, channels: int) -&gt; None:<br \/>\n    &#034;&#034;&#034;\u521d\u59cb\u5316\u901a\u9053\u6ce8\u610f\u529b\u6a21\u5757&#xff0c;\u8bbe\u7f6e\u57fa\u672c\u914d\u7f6e\u3002&#034;&#034;&#034;<br \/>\n    super().__init__()<br \/>\n    self.pool &#061; nn.AdaptiveAvgPool2d(1)  # \u81ea\u9002\u5e94\u5e73\u5747\u6c60\u5316<br \/>\n    self.fc &#061; nn.Conv2d(channels, channels, 1, 1, 0, bias&#061;True)  # 1&#215;1\u5377\u79ef<br \/>\n    self.act &#061; nn.Sigmoid()  # \u6fc0\u6d3b\u51fd\u6570<\/p>\n<p>def forward(self, x: torch.Tensor) -&gt; torch.Tensor:<br \/>\n    &#034;&#034;&#034;\u524d\u5411\u4f20\u64ad&#xff1a;\u8ba1\u7b97\u901a\u9053\u6ce8\u610f\u529b\u5e76\u5e94\u7528\u4e8e\u8f93\u5165\u3002&#034;&#034;&#034;<br \/>\n    return x * self.act(self.fc(self.pool(x)))<\/p>\n<p>class SpatialAttention(nn.Module):<br \/>\n\u201c\u201d\u201c\u7a7a\u95f4\u6ce8\u610f\u529b\u6a21\u5757\u3002\u201d\u201c\u201d<\/p>\n<p>def __init__(self, kernel_size&#061;7):<br \/>\n    &#034;&#034;&#034;\u521d\u59cb\u5316\u7a7a\u95f4\u6ce8\u610f\u529b\u6a21\u5757&#xff0c;\u8bbe\u7f6e\u5377\u79ef\u6838\u5927\u5c0f\u3002&#034;&#034;&#034;<br \/>\n    super().__init__()<br \/>\n    assert kernel_size in {3, 7}, &#034;\u5377\u79ef\u6838\u5927\u5c0f\u5fc5\u987b\u4e3a3\u62167&#034;<br \/>\n    padding &#061; 3 if kernel_size &#061;&#061; 7 else 1<br \/>\n    self.cv1 &#061; nn.Conv2d(2, 1, kernel_size, padding&#061;padding, bias&#061;False)  # \u5377\u79ef\u5c42<br \/>\n    self.act &#061; nn.Sigmoid()  # \u6fc0\u6d3b\u51fd\u6570<\/p>\n<p>def forward(self, x):<br \/>\n    &#034;&#034;&#034;\u524d\u5411\u4f20\u64ad&#xff1a;\u8ba1\u7b97\u7a7a\u95f4\u6ce8\u610f\u529b\u5e76\u5e94\u7528\u4e8e\u8f93\u5165\u3002&#034;&#034;&#034;<br \/>\n    return x * self.act(self.cv1(torch.cat([torch.mean(x, 1, keepdim&#061;True), torch.max(x, 1, keepdim&#061;True)[0]], 1)))<\/p>\n<p>class CBAM(nn.Module):<br \/>\n\u201c\u201d\u201c\u5377\u79ef\u5757\u6ce8\u610f\u529b\u6a21\u5757\u3002\u201d\u201c\u201d<\/p>\n<p>def __init__(self, c1, kernel_size&#061;7):<br \/>\n    &#034;&#034;&#034;\u521d\u59cb\u5316CBAM\u6a21\u5757&#xff0c;\u8bbe\u7f6e\u8f93\u5165\u901a\u9053\u548c\u5377\u79ef\u6838\u5927\u5c0f\u3002&#034;&#034;&#034;<br \/>\n    super().__init__()<br \/>\n    self.channel_attention &#061; ChannelAttention(c1)  # \u901a\u9053\u6ce8\u610f\u529b<br \/>\n    self.spatial_attention &#061; SpatialAttention(kernel_size)  # \u7a7a\u95f4\u6ce8\u610f\u529b<\/p>\n<p>def forward(self, x):<br \/>\n    &#034;&#034;&#034;\u524d\u5411\u4f20\u64ad&#xff1a;\u4f9d\u6b21\u5e94\u7528\u901a\u9053\u6ce8\u610f\u529b\u548c\u7a7a\u95f4\u6ce8\u610f\u529b\u3002&#034;&#034;&#034;<br \/>\n    return self.spatial_attention(self.channel_attention(x))<\/p>\n<p>\u4ee3\u7801\u6838\u5fc3\u90e8\u5206\u8bf4\u660e&#xff1a;<br \/>\nautopad&#xff1a;\u7528\u4e8e\u81ea\u52a8\u8ba1\u7b97\u586b\u5145&#xff0c;\u4ee5\u786e\u4fdd\u5377\u79ef\u64cd\u4f5c\u540e\u8f93\u51fa\u7684\u5f62\u72b6\u4e0e\u8f93\u5165\u5f62\u72b6\u76f8\u540c\u3002<br \/>\nConv&#xff1a;\u6807\u51c6\u5377\u79ef\u5c42&#xff0c;\u5305\u542b\u5377\u79ef\u3001\u6279\u5f52\u4e00\u5316\u548c\u6fc0\u6d3b\u51fd\u6570\u7684\u7ec4\u5408\u3002<br \/>\nDWConv&#xff1a;\u6df1\u5ea6\u5377\u79ef&#xff0c;\u9002\u7528\u4e8e\u6df1\u5ea6\u53ef\u5206\u79bb\u5377\u79ef\u7684\u5b9e\u73b0\u3002<br \/>\nDSConv&#xff1a;\u6df1\u5ea6\u53ef\u5206\u79bb\u5377\u79ef\u6a21\u5757&#xff0c;\u5305\u542b\u6df1\u5ea6\u5377\u79ef\u548c\u9010\u70b9\u5377\u79ef\u3002<br \/>\nConvTranspose&#xff1a;\u8f6c\u7f6e\u5377\u79ef\u5c42&#xff0c;\u901a\u5e38\u7528\u4e8e\u4e0a\u91c7\u6837\u3002<br \/>\nChannelAttention&#xff1a;\u901a\u9053\u6ce8\u610f\u529b\u673a\u5236&#xff0c;\u901a\u8fc7\u5bf9\u901a\u9053\u8fdb\u884c\u52a0\u6743\u6765\u589e\u5f3a\u7279\u5f81\u3002<br \/>\nSpatialAttention&#xff1a;\u7a7a\u95f4\u6ce8\u610f\u529b\u673a\u5236&#xff0c;\u901a\u8fc7\u5bf9\u7a7a\u95f4\u4f4d\u7f6e\u8fdb\u884c\u52a0\u6743\u6765\u589e\u5f3a\u7279\u5f81\u3002<br \/>\nCBAM&#xff1a;\u7ed3\u5408\u901a\u9053\u548c\u7a7a\u95f4\u6ce8\u610f\u529b\u7684\u6a21\u5757&#xff0c;\u63d0\u5347\u7279\u5f81\u8868\u8fbe\u80fd\u529b\u3002<br \/>\n\u8fd9\u4e2a\u7a0b\u5e8f\u6587\u4ef6 conv.py \u5b9a\u4e49\u4e86\u4e00\u7cfb\u5217\u7528\u4e8e\u5377\u79ef\u64cd\u4f5c\u7684\u6a21\u5757&#xff0c;\u4e3b\u8981\u7528\u4e8e\u6df1\u5ea6\u5b66\u4e60\u4e2d\u7684\u5377\u79ef\u795e\u7ecf\u7f51\u7edc&#xff08;CNN&#xff09;\u3002\u6587\u4ef6\u4e2d\u4f7f\u7528\u4e86 PyTorch \u6846\u67b6&#xff0c;\u5e76\u5b9e\u73b0\u4e86\u591a\u79cd\u5377\u79ef\u5c42\u548c\u6ce8\u610f\u529b\u673a\u5236\u3002\u4ee5\u4e0b\u662f\u5bf9\u4ee3\u7801\u7684\u8be6\u7ec6\u8bf4\u660e\u3002<\/p>\n<p>\u9996\u5148&#xff0c;\u6587\u4ef6\u5bfc\u5165\u4e86\u5fc5\u8981\u7684\u5e93&#xff0c;\u5305\u62ec math\u3001numpy \u548c torch \u4ee5\u53ca torch.nn\u3002\u63a5\u7740&#xff0c;\u5b9a\u4e49\u4e86\u4e00\u4e2a\u540d\u4e3a autopad \u7684\u51fd\u6570&#xff0c;\u8be5\u51fd\u6570\u7528\u4e8e\u81ea\u52a8\u8ba1\u7b97\u5377\u79ef\u64cd\u4f5c\u6240\u9700\u7684\u586b\u5145&#xff0c;\u4ee5\u786e\u4fdd\u8f93\u51fa\u7684\u5f62\u72b6\u4e0e\u8f93\u5165\u7684\u5f62\u72b6\u76f8\u540c\u3002<\/p>\n<p>\u63a5\u4e0b\u6765&#xff0c;\u5b9a\u4e49\u4e86\u591a\u4e2a\u5377\u79ef\u7c7b\u3002Conv \u7c7b\u5b9e\u73b0\u4e86\u6807\u51c6\u7684\u5377\u79ef\u64cd\u4f5c&#xff0c;\u5305\u542b\u5377\u79ef\u5c42\u3001\u6279\u5f52\u4e00\u5316\u5c42\u548c\u6fc0\u6d3b\u51fd\u6570\u3002\u6784\u9020\u51fd\u6570\u4e2d\u63a5\u53d7\u591a\u4e2a\u53c2\u6570&#xff0c;\u5982\u8f93\u5165\u901a\u9053\u6570\u3001\u8f93\u51fa\u901a\u9053\u6570\u3001\u5377\u79ef\u6838\u5927\u5c0f\u3001\u6b65\u5e45\u3001\u586b\u5145\u3001\u5206\u7ec4\u5377\u79ef\u548c\u6269\u5f20\u7b49\u3002forward \u65b9\u6cd5\u5b9e\u73b0\u4e86\u5377\u79ef\u3001\u6279\u5f52\u4e00\u5316\u548c\u6fc0\u6d3b\u7684\u987a\u5e8f\u64cd\u4f5c\u3002<\/p>\n<p>Conv2 \u7c7b\u662f Conv \u7c7b\u7684\u7b80\u5316\u7248\u672c&#xff0c;\u589e\u52a0\u4e86\u4e00\u4e2a 1&#215;1 \u7684\u5377\u79ef\u5c42&#xff0c;\u4ee5\u4fbf\u5728\u524d\u5411\u4f20\u64ad\u4e2d\u878d\u5408\u4e24\u4e2a\u5377\u79ef\u7684\u8f93\u51fa\u3002LightConv \u7c7b\u5b9e\u73b0\u4e86\u4e00\u79cd\u8f7b\u91cf\u7ea7\u5377\u79ef&#xff0c;\u7ed3\u5408\u4e86\u6807\u51c6\u5377\u79ef\u548c\u6df1\u5ea6\u5377\u79ef&#xff08;DWConv&#xff09;&#xff0c;\u7528\u4e8e\u63d0\u9ad8\u8ba1\u7b97\u6548\u7387\u3002<\/p>\n<p>DWConv \u7c7b\u5b9e\u73b0\u4e86\u6df1\u5ea6\u5377\u79ef&#xff0c;\u9002\u7528\u4e8e\u6bcf\u4e2a\u8f93\u5165\u901a\u9053\u72ec\u7acb\u8fdb\u884c\u5377\u79ef\u64cd\u4f5c\u3002DSConv \u7c7b\u5219\u5b9e\u73b0\u4e86\u6df1\u5ea6\u53ef\u5206\u79bb\u5377\u79ef&#xff0c;\u7ed3\u5408\u4e86\u6df1\u5ea6\u5377\u79ef\u548c\u9010\u70b9\u5377\u79ef\u7684\u7279\u70b9\u3002<\/p>\n<p>DWConvTranspose2d \u7c7b\u5b9e\u73b0\u4e86\u6df1\u5ea6\u8f6c\u7f6e\u5377\u79ef&#xff0c;\u800c ConvTranspose \u7c7b\u5219\u5b9e\u73b0\u4e86\u6807\u51c6\u7684\u8f6c\u7f6e\u5377\u79ef\u5c42&#xff0c;\u652f\u6301\u6279\u5f52\u4e00\u5316\u548c\u6fc0\u6d3b\u51fd\u6570\u3002<\/p>\n<p>Focus \u7c7b\u7528\u4e8e\u5c06\u7a7a\u95f4\u4fe1\u606f\u805a\u7126\u5230\u901a\u9053\u7ef4\u5ea6&#xff0c;\u901a\u8fc7\u5bf9\u8f93\u5165\u5f20\u91cf\u8fdb\u884c\u7279\u5b9a\u7684\u5207\u7247\u548c\u62fc\u63a5&#xff0c;\u589e\u52a0\u4e86\u5377\u79ef\u7684\u8f93\u5165\u901a\u9053\u6570\u3002GhostConv \u7c7b\u5b9e\u73b0\u4e86 Ghost \u5377\u79ef&#xff0c;\u901a\u8fc7\u4e3b\u5377\u79ef\u548c\u5ec9\u4ef7\u64cd\u4f5c\u6765\u63d0\u9ad8\u7279\u5f81\u5b66\u4e60\u7684\u6548\u7387\u3002<\/p>\n<p>RepConv \u7c7b\u662f\u4e00\u4e2a\u57fa\u7840\u7684\u91cd\u590d\u5377\u79ef\u6a21\u5757&#xff0c;\u652f\u6301\u8bad\u7ec3\u548c\u63a8\u7406\u9636\u6bb5\u7684\u4e0d\u540c\u64cd\u4f5c\u3002\u5b83\u901a\u8fc7\u878d\u5408\u5377\u79ef\u548c\u6279\u5f52\u4e00\u5316\u7684\u53c2\u6570\u6765\u4f18\u5316\u6a21\u578b\u3002<\/p>\n<p>\u63a5\u4e0b\u6765&#xff0c;\u5b9a\u4e49\u4e86\u51e0\u4e2a\u6ce8\u610f\u529b\u673a\u5236\u6a21\u5757\u3002ChannelAttention \u7c7b\u5b9e\u73b0\u4e86\u901a\u9053\u6ce8\u610f\u529b\u673a\u5236&#xff0c;\u901a\u8fc7\u5bf9\u8f93\u5165\u7279\u5f81\u56fe\u8fdb\u884c\u5168\u5c40\u5e73\u5747\u6c60\u5316\u548c\u5168\u8fde\u63a5\u5c42\u64cd\u4f5c&#xff0c;\u751f\u6210\u901a\u9053\u6743\u91cd\u3002SpatialAttention \u7c7b\u5b9e\u73b0\u4e86\u7a7a\u95f4\u6ce8\u610f\u529b\u673a\u5236&#xff0c;\u901a\u8fc7\u5bf9\u8f93\u5165\u7279\u5f81\u56fe\u8fdb\u884c\u5e73\u5747\u548c\u6700\u5927\u6c60\u5316&#xff0c;\u751f\u6210\u7a7a\u95f4\u6743\u91cd\u3002<\/p>\n<p>CBAM \u7c7b\u7ed3\u5408\u4e86\u901a\u9053\u6ce8\u610f\u529b\u548c\u7a7a\u95f4\u6ce8\u610f\u529b&#xff0c;\u5f62\u6210\u4e00\u4e2a\u5b8c\u6574\u7684\u5377\u79ef\u5757\u6ce8\u610f\u529b\u6a21\u5757&#xff0c;\u7528\u4e8e\u7279\u5f81\u7684\u91cd\u6821\u51c6\u3002<\/p>\n<p>\u6700\u540e&#xff0c;Concat \u7c7b\u5b9e\u73b0\u4e86\u5f20\u91cf\u7684\u62fc\u63a5\u64cd\u4f5c&#xff0c;\u53ef\u4ee5\u5728\u6307\u5b9a\u7684\u7ef4\u5ea6\u4e0a\u5c06\u591a\u4e2a\u5f20\u91cf\u8fde\u63a5\u8d77\u6765\u3002<\/p>\n<p>\u6574\u4f53\u6765\u770b&#xff0c;\u8fd9\u4e2a\u6587\u4ef6\u5b9e\u73b0\u4e86\u591a\u79cd\u5377\u79ef\u548c\u6ce8\u610f\u529b\u673a\u5236\u6a21\u5757&#xff0c;\u4e3a\u6784\u5efa\u590d\u6742\u7684\u5377\u79ef\u795e\u7ecf\u7f51\u7edc\u63d0\u4f9b\u4e86\u57fa\u7840\u7ec4\u4ef6\u3002\u8fd9\u4e9b\u6a21\u5757\u53ef\u4ee5\u7075\u6d3b\u7ec4\u5408&#xff0c;\u9002\u7528\u4e8e\u5404\u79cd\u8ba1\u7b97\u673a\u89c6\u89c9\u4efb\u52a1\u3002<\/p>\n<p>10.4 prepbn.py<br \/>\n\u4ee5\u4e0b\u662f\u7ecf\u8fc7\u7b80\u5316\u5e76\u6ce8\u91ca\u7684\u6838\u5fc3\u4ee3\u7801\u90e8\u5206&#xff1a;<\/p>\n<p>import torch<br \/>\nimport torch.nn as nn<\/p>\n<p>\u81ea\u5b9a\u4e49\u7684\u6279\u91cf\u5f52\u4e00\u5316\u7c7b<br \/>\nclass RepBN(nn.Module):<br \/>\ndef init(self, channels):<br \/>\nsuper(RepBN, self).init()<br \/>\n# alpha \u662f\u4e00\u4e2a\u53ef\u5b66\u4e60\u7684\u53c2\u6570&#xff0c;\u521d\u59cb\u5316\u4e3a1<br \/>\nself.alpha &#061; nn.Parameter(torch.ones(1))<br \/>\n# \u4f7f\u7528\u4e00\u7ef4\u6279\u91cf\u5f52\u4e00\u5316<br \/>\nself.bn &#061; nn.BatchNorm1d(channels)<\/p>\n<p>def forward(self, x):<br \/>\n    # \u5c06\u8f93\u5165\u7684\u7ef4\u5ea6\u8fdb\u884c\u8f6c\u7f6e&#xff0c;\u4ee5\u9002\u5e94 BatchNorm1d \u7684\u8f93\u5165\u683c\u5f0f<br \/>\n    x &#061; x.transpose(1, 2)<br \/>\n    # \u8fdb\u884c\u6279\u91cf\u5f52\u4e00\u5316&#xff0c;\u5e76\u52a0\u4e0a alpha \u4e58\u4ee5\u539f\u59cb\u8f93\u5165<br \/>\n    x &#061; self.bn(x) &#043; self.alpha * x<br \/>\n    # \u518d\u6b21\u8f6c\u7f6e\u56de\u539f\u6765\u7684\u7ef4\u5ea6<br \/>\n    x &#061; x.transpose(1, 2)<br \/>\n    return x<\/p>\n<p>\u81ea\u5b9a\u4e49\u7684\u7ebf\u6027\u5f52\u4e00\u5316\u7c7b<br \/>\nclass LinearNorm(nn.Module):<br \/>\ndef init(self, dim, norm1, norm2, warm&#061;0, step&#061;300000, r0&#061;1.0):<br \/>\nsuper(LinearNorm, self).init()<br \/>\n# \u6ce8\u518c\u4e00\u4e9b\u7f13\u51b2\u533a&#xff0c;\u7528\u4e8e\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u7684\u72b6\u6001\u7ba1\u7406<br \/>\nself.register_buffer(\u2018warm\u2019, torch.tensor(warm))  # \u9884\u70ed\u6b65\u6570<br \/>\nself.register_buffer(\u2018iter\u2019, torch.tensor(step))   # \u5f53\u524d\u8fed\u4ee3\u6b65\u6570<br \/>\nself.register_buffer(\u2018total_step\u2019, torch.tensor(step))  # \u603b\u6b65\u6570<br \/>\nself.r0 &#061; r0  # \u521d\u59cb\u6bd4\u4f8b<br \/>\nself.norm1 &#061; norm1(dim)  # \u7b2c\u4e00\u4e2a\u5f52\u4e00\u5316\u5c42<br \/>\nself.norm2 &#061; norm2(dim)  # \u7b2c\u4e8c\u4e2a\u5f52\u4e00\u5316\u5c42<\/p>\n<p>def forward(self, x):<br \/>\n    if self.training:  # \u8bad\u7ec3\u6a21\u5f0f<br \/>\n        if self.warm &gt; 0:  # \u5982\u679c\u8fd8\u6709\u9884\u70ed\u6b65\u6570<br \/>\n            self.warm.copy_(self.warm &#8211; 1)  # \u51cf\u5c11\u9884\u70ed\u6b65\u6570<br \/>\n            x &#061; self.norm1(x)  # \u8fdb\u884c\u7b2c\u4e00\u6b21\u5f52\u4e00\u5316<br \/>\n        else:<br \/>\n            # \u8ba1\u7b97\u5f53\u524d\u7684 lambda \u503c&#xff0c;\u7528\u4e8e\u7ebf\u6027\u63d2\u503c<br \/>\n            lamda &#061; self.r0 * self.iter \/ self.total_step<br \/>\n            if self.iter &gt; 0:<br \/>\n                self.iter.copy_(self.iter &#8211; 1)  # \u51cf\u5c11\u8fed\u4ee3\u6b65\u6570<br \/>\n            x1 &#061; self.norm1(x)  # \u7b2c\u4e00\u6b21\u5f52\u4e00\u5316<br \/>\n            x2 &#061; self.norm2(x)  # \u7b2c\u4e8c\u6b21\u5f52\u4e00\u5316<br \/>\n            # \u7ebf\u6027\u63d2\u503c<br \/>\n            x &#061; lamda * x1 &#043; (1 &#8211; lamda) * x2<br \/>\n    else:  # \u6d4b\u8bd5\u6a21\u5f0f<br \/>\n        x &#061; self.norm2(x)  # \u53ea\u8fdb\u884c\u7b2c\u4e8c\u6b21\u5f52\u4e00\u5316<br \/>\n    return x<\/p>\n<p>\u4ee3\u7801\u8bf4\u660e&#xff1a;<br \/>\nRepBN \u7c7b&#xff1a;<\/p>\n<p>\u8be5\u7c7b\u5b9e\u73b0\u4e86\u4e00\u79cd\u81ea\u5b9a\u4e49\u7684\u6279\u91cf\u5f52\u4e00\u5316\u65b9\u6cd5&#xff0c;\u5141\u8bb8\u901a\u8fc7\u4e00\u4e2a\u53ef\u5b66\u4e60\u7684\u53c2\u6570 alpha \u6765\u8c03\u6574\u5f52\u4e00\u5316\u7684\u8f93\u51fa\u3002<br \/>\n\u5728 forward \u65b9\u6cd5\u4e2d&#xff0c;\u8f93\u5165\u6570\u636e\u7684\u7ef4\u5ea6\u88ab\u8f6c\u7f6e&#xff0c;\u4ee5\u9002\u5e94 BatchNorm1d \u7684\u8981\u6c42&#xff0c;\u7ecf\u8fc7\u5f52\u4e00\u5316\u540e&#xff0c;\u518d\u52a0\u4e0a alpha \u4e58\u4ee5\u539f\u59cb\u8f93\u5165\u3002<br \/>\nLinearNorm \u7c7b&#xff1a;<\/p>\n<p>\u8be5\u7c7b\u5b9e\u73b0\u4e86\u4e00\u79cd\u7ebf\u6027\u5f52\u4e00\u5316\u65b9\u6cd5&#xff0c;\u7ed3\u5408\u4e86\u4e24\u4e2a\u4e0d\u540c\u7684\u5f52\u4e00\u5316\u5c42&#xff08;norm1 \u548c norm2&#xff09;\u3002<br \/>\n\u5728\u8bad\u7ec3\u8fc7\u7a0b\u4e2d&#xff0c;\u4f7f\u7528\u9884\u70ed\u9636\u6bb5\u9010\u6b65\u5f15\u5165 norm1&#xff0c;\u7136\u540e\u6839\u636e\u5f53\u524d\u7684\u8fed\u4ee3\u6b65\u6570\u8ba1\u7b97\u4e00\u4e2a\u7ebf\u6027\u63d2\u503c\u7cfb\u6570 lambda&#xff0c;\u5728 norm1 \u548c norm2 \u4e4b\u95f4\u8fdb\u884c\u52a0\u6743\u3002<br \/>\n\u5728\u6d4b\u8bd5\u6a21\u5f0f\u4e0b&#xff0c;\u53ea\u4f7f\u7528 norm2 \u8fdb\u884c\u5f52\u4e00\u5316\u3002<br \/>\n\u8fd9\u4e2a\u7a0b\u5e8f\u6587\u4ef6\u5b9a\u4e49\u4e86\u4e24\u4e2a\u795e\u7ecf\u7f51\u7edc\u6a21\u5757&#xff0c;\u5206\u522b\u662f RepBN \u548c LinearNorm&#xff0c;\u5b83\u4eec\u90fd\u662f\u57fa\u4e8e PyTorch \u6846\u67b6\u6784\u5efa\u7684\u3002<\/p>\n<p>RepBN \u7c7b\u662f\u4e00\u4e2a\u81ea\u5b9a\u4e49\u7684\u6279\u91cf\u5f52\u4e00\u5316\u5c42&#xff0c;\u7ee7\u627f\u81ea nn.Module\u3002\u5728\u521d\u59cb\u5316\u65b9\u6cd5\u4e2d&#xff0c;\u5b83\u63a5\u53d7\u4e00\u4e2a\u53c2\u6570 channels&#xff0c;\u7528\u4e8e\u6307\u5b9a\u8f93\u5165\u6570\u636e\u7684\u901a\u9053\u6570\u3002\u8be5\u7c7b\u5b9a\u4e49\u4e86\u4e00\u4e2a\u53ef\u5b66\u4e60\u7684\u53c2\u6570 alpha&#xff0c;\u521d\u59cb\u503c\u4e3a 1&#xff0c;\u5e76\u521b\u5efa\u4e86\u4e00\u4e2a\u6807\u51c6\u7684\u6279\u91cf\u5f52\u4e00\u5316\u5c42 bn\u3002\u5728\u524d\u5411\u4f20\u64ad\u65b9\u6cd5 forward \u4e2d&#xff0c;\u8f93\u5165\u5f20\u91cf x \u9996\u5148\u8fdb\u884c\u7ef4\u5ea6\u8f6c\u7f6e&#xff0c;\u5c06\u901a\u9053\u7ef4\u79fb\u5230\u6700\u540e&#xff0c;\u7136\u540e\u901a\u8fc7\u6279\u91cf\u5f52\u4e00\u5316\u5c42\u8fdb\u884c\u5904\u7406\u3002\u5904\u7406\u540e&#xff0c;\u7ed3\u679c\u4e0e alpha \u4e58\u4ee5\u539f\u59cb\u8f93\u5165 x \u76f8\u52a0&#xff0c;\u6700\u540e\u518d\u8fdb\u884c\u4e00\u6b21\u7ef4\u5ea6\u8f6c\u7f6e\u4ee5\u6062\u590d\u539f\u6765\u7684\u5f62\u72b6\u3002\u8fd9\u4e2a\u6a21\u5757\u7684\u8bbe\u8ba1\u76ee\u7684\u662f\u5728\u6807\u51c6\u7684\u6279\u91cf\u5f52\u4e00\u5316\u57fa\u7840\u4e0a\u5f15\u5165\u4e00\u4e2a\u53ef\u8c03\u7684\u52a0\u6743\u9879&#xff0c;\u4ee5\u589e\u5f3a\u6a21\u578b\u7684\u8868\u8fbe\u80fd\u529b\u3002<\/p>\n<p>LinearNorm \u7c7b\u540c\u6837\u7ee7\u627f\u81ea nn.Module&#xff0c;\u5b83\u7684\u6784\u9020\u51fd\u6570\u63a5\u53d7\u591a\u4e2a\u53c2\u6570&#xff0c;\u5305\u62ec dim&#xff08;\u8f93\u5165\u7684\u7ef4\u5ea6&#xff09;\u3001norm1 \u548c norm2&#xff08;\u4e24\u4e2a\u5f52\u4e00\u5316\u51fd\u6570&#xff09;\u3001warm&#xff08;\u9884\u70ed\u6b65\u6570&#xff09;\u3001step&#xff08;\u5f53\u524d\u6b65\u6570&#xff09;\u548c r0&#xff08;\u521d\u59cb\u6743\u91cd&#xff09;\u3002\u5728\u521d\u59cb\u5316\u8fc7\u7a0b\u4e2d&#xff0c;\u4f7f\u7528 register_buffer \u65b9\u6cd5\u6ce8\u518c\u4e86\u4e00\u4e9b\u7f13\u51b2\u533a\u53d8\u91cf&#xff0c;\u8fd9\u4e9b\u53d8\u91cf\u5728\u6a21\u578b\u8bad\u7ec3\u8fc7\u7a0b\u4e2d\u4f1a\u4fdd\u6301\u5176\u72b6\u6001\u3002\u524d\u5411\u4f20\u64ad\u65b9\u6cd5 forward \u7684\u903b\u8f91\u8f83\u4e3a\u590d\u6742&#xff1a;\u5982\u679c\u6a21\u578b\u5904\u4e8e\u8bad\u7ec3\u72b6\u6001\u4e14\u9884\u70ed\u6b65\u6570\u5927\u4e8e 0&#xff0c;\u5219\u6267\u884c\u7b2c\u4e00\u6b21\u5f52\u4e00\u5316 norm1&#xff0c;\u5e76\u5c06\u9884\u70ed\u6b65\u6570\u51cf\u4e00&#xff1b;\u5426\u5219&#xff0c;\u8ba1\u7b97\u4e00\u4e2a\u6743\u91cd lamda&#xff0c;\u5b83\u4e0e\u5f53\u524d\u8fed\u4ee3\u6b65\u6570\u548c\u603b\u6b65\u6570\u6709\u5173\u3002\u63a5\u7740&#xff0c;\u5206\u522b\u5bf9\u8f93\u5165 x \u5e94\u7528\u4e24\u4e2a\u5f52\u4e00\u5316\u64cd\u4f5c norm1 \u548c norm2&#xff0c;\u5e76\u6839\u636e\u8ba1\u7b97\u51fa\u7684\u6743\u91cd\u5c06\u8fd9\u4e24\u4e2a\u7ed3\u679c\u8fdb\u884c\u7ebf\u6027\u7ec4\u5408\u3002\u82e5\u6a21\u578b\u4e0d\u5728\u8bad\u7ec3\u72b6\u6001&#xff0c;\u5219\u76f4\u63a5\u4f7f\u7528 norm2 \u5bf9\u8f93\u5165\u8fdb\u884c\u5f52\u4e00\u5316\u5904\u7406\u3002<\/p>\n<p>\u603b\u4f53\u800c\u8a00&#xff0c;\u8fd9\u4e24\u4e2a\u6a21\u5757\u901a\u8fc7\u81ea\u5b9a\u4e49\u7684\u5f52\u4e00\u5316\u65b9\u6cd5\u548c\u52a8\u6001\u8c03\u6574\u7684\u6743\u91cd&#xff0c;\u65e8\u5728\u63d0\u9ad8\u795e\u7ecf\u7f51\u7edc\u7684\u8bad\u7ec3\u6548\u679c\u548c\u7a33\u5b9a\u6027\u3002<\/p>\n<h2>\u6e90\u7801\u6587\u4ef6<\/h2>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810223451-68991e8b5ecf1.png\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>\u6e90\u7801\u83b7\u53d6<\/h2>\n<p>\u6b22\u8fce\u5927\u5bb6\u70b9\u8d5e\u3001\u6536\u85cf\u3001\u5173\u6ce8\u3001\u8bc4\u8bba\u5566 \u3001\u67e5\u770b&#x1f447;&#x1f3fb;\u83b7\u53d6\u8054\u7cfb\u65b9\u5f0f<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb147\u6b21\u3002\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u8bc6\u522b\u7cfb\u7edf\u6e90\u7801\u548c\u6570\u636e\u96c6\uff1a\u6539\u8fdbyolo11-RevCol<\/p>\n","protected":false},"author":2,"featured_media":51755,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,156,2842,5134,1908,5137,523,5132],"topic":[],"class_list":["post-51764","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-python","tag-yolo","tag-yolo11","tag-5134","tag-1908","tag-5137","tag-523","tag-5132"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u8bc6\u522b\u7cfb\u7edf\u6e90\u7801\u548c\u6570\u636e\u96c6\uff1a\u6539\u8fdbyolo11-RevCol - \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\/51764.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u8bc6\u522b\u7cfb\u7edf\u6e90\u7801\u548c\u6570\u636e\u96c6\uff1a\u6539\u8fdbyolo11-RevCol - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb147\u6b21\u3002\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u8bc6\u522b\u7cfb\u7edf\u6e90\u7801\u548c\u6570\u636e\u96c6\uff1a\u6539\u8fdbyolo11-RevCol\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/51764.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-10T22:34:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810223447-68991e870ae8c.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=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/51764.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/51764.html\",\"name\":\"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u8bc6\u522b\u7cfb\u7edf\u6e90\u7801\u548c\u6570\u636e\u96c6\uff1a\u6539\u8fdbyolo11-RevCol - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-10T22:34:52+00:00\",\"dateModified\":\"2025-08-10T22:34:52+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/51764.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/51764.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/51764.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u8bc6\u522b\u7cfb\u7edf\u6e90\u7801\u548c\u6570\u636e\u96c6\uff1a\u6539\u8fdbyolo11-RevCol\"}]},{\"@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":"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u8bc6\u522b\u7cfb\u7edf\u6e90\u7801\u548c\u6570\u636e\u96c6\uff1a\u6539\u8fdbyolo11-RevCol - \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\/51764.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u8bc6\u522b\u7cfb\u7edf\u6e90\u7801\u548c\u6570\u636e\u96c6\uff1a\u6539\u8fdbyolo11-RevCol - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb147\u6b21\u3002\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u8bc6\u522b\u7cfb\u7edf\u6e90\u7801\u548c\u6570\u636e\u96c6\uff1a\u6539\u8fdbyolo11-RevCol","og_url":"https:\/\/www.wsisp.com\/helps\/51764.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-10T22:34:52+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/08\/20250810223447-68991e870ae8c.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/51764.html","url":"https:\/\/www.wsisp.com\/helps\/51764.html","name":"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u8bc6\u522b\u7cfb\u7edf\u6e90\u7801\u548c\u6570\u636e\u96c6\uff1a\u6539\u8fdbyolo11-RevCol - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-10T22:34:52+00:00","dateModified":"2025-08-10T22:34:52+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/51764.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/51764.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/51764.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010\u5b8c\u6574\u6e90\u7801+\u6570\u636e\u96c6+\u90e8\u7f72\u6559\u7a0b\u3011\u7535\u6c14\u8bbe\u5907\u90e8\u4ef6\u8bc6\u522b\u7cfb\u7edf\u6e90\u7801\u548c\u6570\u636e\u96c6\uff1a\u6539\u8fdbyolo11-RevCol"}]},{"@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\/51764","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=51764"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/51764\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/51755"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=51764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=51764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=51764"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=51764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}