{"id":112757,"date":"2026-10-04T20:17:24","date_gmt":"2026-10-04T12:17:24","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/112757.html"},"modified":"2026-10-04T20:17:24","modified_gmt":"2026-10-04T12:17:24","slug":"%e3%80%90%e5%8c%bb%e5%ad%a6%e5%9b%be%e5%83%8f%e5%88%86%e5%89%b2%e6%a8%a1%e5%9d%97%e3%80%91biformer-%e5%8f%8c%e5%b1%82%e8%b7%af%e7%94%b1%e6%b3%a8%e6%84%8f%e5%8a%9b%ef%bc%88cvpr-2023%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/112757.html","title":{"rendered":"\u3010\u533b\u5b66\u56fe\u50cf\u5206\u5272\u6a21\u5757\u3011BiFormer \/ \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b\uff08CVPR 2023\uff09\u2014\u2014\u53ea\u7b97\u201c\u8be5\u7b97\u7684\u5730\u65b9\u201c\u7684\u7a00\u758f\u6ce8\u610f\u529b"},"content":{"rendered":"<h2>\u3010\u533b\u5b66\u56fe\u50cf\u5206\u5272\u6a21\u5757\u3011BiFormer \/ \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b&#xff08;CVPR 2023&#xff09;\u2014\u2014 \u53ea\u7b97&#034;\u8be5\u7b97\u7684\u5730\u65b9&#034;\u7684\u7a00\u758f\u6ce8\u610f\u529b<\/h2>\n<p>\u533b\u5b66\u56fe\u50cf\u5206\u5272\u91cc\u5230\u5904\u662f\u9ad8\u5206\u8fa8\u7387\u7279\u5f81\u56fe\u3002\u76f4\u63a5\u4e0a\u5168\u5c40\u6ce8\u610f\u529b&#xff08;Self-Attention&#xff09;\u6709\u4e24\u4e2a\u8001\u95ee\u9898&#xff1a;\u4e00\u662f\u8ba1\u7b97\u91cf\u968f token \u6570\u5e73\u65b9\u7ea7\u7206\u70b8&#xff1b;\u4e8c\u662f\u5927\u90e8\u5206\u533a\u57df\u5176\u5b9e\u6beb\u65e0\u5173\u7cfb&#xff08;\u6bd4\u5982\u80bf\u7624\u533a\u548c\u80cc\u666f\u533a&#xff09;&#xff0c;\u5374\u8981\u4e24\u4e24\u7b97\u4e00\u904d\u2014\u2014\u53c8\u6162\u53c8\u6d6a\u8d39\u3002<\/p>\n<p>BiFormer&#xff08;CVPR 2023&#xff09;\u63d0\u51fa \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b&#xff08;Bi-Level Routing Attention, BRA&#xff09;&#xff1a;\u5148\u5728\u533a\u57df&#xff08;region&#xff09;\u5c42\u9762\u7c97\u7b5b\u51fa\u6bcf\u4e2a\u533a\u57df\u6700\u76f8\u5173\u7684\u5c11\u6570\u51e0\u4e2a\u533a\u57df&#xff0c;\u518d\u53ea\u5728\u7b5b\u51fa\u6765\u7684\u533a\u57df\u91cc\u505a\u7ec6\u7c92\u5ea6 token-to-token \u6ce8\u610f\u529b\u3002\u6ce8\u610f\u529b\u53d8\u6210&#034;\u5185\u5bb9\u611f\u77e5\u7684\u7a00\u758f\u6ce8\u610f\u529b&#034;\u2014\u2014\u8be5\u7b97\u7684\u624d\u7b97&#xff0c;\u8ba1\u7b97\u91cf\u5927\u5e45\u4e0b\u964d&#xff0c;\u800c\u5173\u952e\u4fe1\u606f\u4e0d\u4e22\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u8bba\u6587\u51fa\u5904<\/h3>\n<ul>\n<li>\u8bba\u6587&#xff1a;BiFormer: Vision Transformer with Bi-Level Routing Attention<\/li>\n<li>\u4f1a\u8bae&#xff1a;CVPR 2023<\/li>\n<li>\u8bba\u6587\u94fe\u63a5&#xff1a;https:\/\/arxiv.org\/abs\/2303.08810<\/li>\n<li>\u5b98\u65b9\u4ee3\u7801&#xff1a;https:\/\/github.com\/rayleizhu\/BiFormer<\/li>\n<\/ul>\n<hr \/>\n<h3>\u4e8c\u3001\u6a21\u5757\u56fe&#xff08;\u622a\u81ea\u8bba\u6587\u539f\u6587 Figure 3&#xff09;<\/h3>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261004121723-6ac243d343fc4.png\" alt=\"BiFormer \u6574\u4f53\u67b6\u6784\u56fe\uff08\u539f\u6587 Figure 3\uff09\" \/><\/p>\n<p>\u56fe\u81ea BiFormer \u539f\u6587 Figure 3&#xff08;CVPR 2023&#xff09;\u3002\u5de6\u534a\u662f\u6574\u4f53\u91d1\u5b57\u5854\u67b6\u6784&#xff1a;Input \u2192 Stage 1~4&#xff0c;\u6bcf\u4e2a Stage \u7531 Patch Embedding \/ Patch Merging &#043; \u82e5\u5e72 BiFormer Block \u7ec4\u6210&#xff0c;\u5206\u8fa8\u7387\u9010\u7ea7\u51cf\u534a\u3001\u901a\u9053\u9010\u7ea7\u7ffb\u500d&#xff1b;\u53f3\u534a\u865a\u7ebf\u6846\u5c55\u5f00 BiFormer Block \u7684\u5185\u90e8&#xff08;DWConv 3\u00d73 \u2192 LN \u2192 Bi-level Routing Attention \u2192 LN \u2192 MLP&#xff0c;\u5e26\u6b8b\u5dee&#xff09;\u3002<\/p>\n<p>&#xff08;\u4e00\u53e5\u8bdd&#xff1a;\u4e3b\u5e72\u662f\u5206\u5c42 ViT&#xff0c;\u6838\u5fc3\u662f\u91cc\u9762\u7684 BRA \u6ce8\u610f\u529b\u2014\u2014\u5148\u5728\u533a\u57df\u5c42\u8def\u7531&#xff0c;\u518d\u5728\u5c11\u6570\u76f8\u5173\u533a\u57df\u91cc\u505a\u6ce8\u610f\u529b\u3002&#xff09;<\/p>\n<hr \/>\n<h3>\u4e09\u3001\u6838\u5fc3\u601d\u60f3\u4e0e\u4f5c\u7528<\/h3>\n<p>\u4e00\u53e5\u8bdd&#xff1a;\u6ce8\u610f\u529b\u522b\u5168\u7b97\u2014\u2014\u5148\u5728&#034;\u533a\u57df&#034;\u5c42\u9762\u6311\u51fa\u76f8\u5173\u7684\u5c11\u90e8\u5206\u533a\u57df&#xff0c;\u53ea\u5728\u91cc\u9762\u505a token-to-token \u6ce8\u610f\u529b\u3002<\/p>\n<p>\u62c6\u89e3\u4e24\u6b65&#xff08;&#034;\u53cc\u5c42&#034;\u5c31\u5728\u8fd9&#xff09;&#xff1a;<\/p>\n<li>\u533a\u57df\u7ea7\u8def\u7531&#xff08;\u7c97\u7b5b&#xff09;&#xff1a;\u628a\u7279\u5f81\u56fe\u5207\u6210 n\u00d7n \u4e2a\u4e0d\u91cd\u53e0\u533a\u57df&#xff1b;\u5bf9\u6bcf\u4e2a\u533a\u57df\u7b97\u5b83\u548c\u5176\u4ed6\u533a\u57df\u7684\u76f8\u5173\u5ea6&#xff0c;\u53ea\u4fdd\u7559 top-k \u4e2a\u6700\u76f8\u5173\u7684\u533a\u57df&#xff0c;\u5176\u4f59\u4e22\u5f03\u3002<\/li>\n<li>token \u7ea7\u6ce8\u610f\u529b&#xff08;\u7ec6\u7b97&#xff09;&#xff1a;\u628a\u4e0a\u4e00\u6b65\u9009\u4e2d\u7684 top-k \u533a\u57df\u91cc\u7684 key\/value \u805a\u5230\u4e00\u8d77&#xff0c;\u8ba9\u672c\u533a\u57df\u7684\u6bcf\u4e2a token \u53ea\u5bf9\u8fd9\u4e00\u5c0f\u64ae key\/value \u505a\u6ce8\u610f\u529b\u3002<\/li>\n<p>\u4e3a\u4ec0\u4e48\u597d&#xff1a;<\/p>\n<ul>\n<li>\u8ba1\u7b97\u91cf&#xff1a;\u4ece&#034;\u5168\u56fe\u4e24\u4e24\u7b97&#034;\u964d\u5230&#034;\u6bcf\u4e2a\u533a\u57df\u53ea\u548c top-k \u4e2a\u533a\u57df\u7b97&#034;&#xff0c;\u590d\u6742\u5ea6\u663e\u8457\u4e0b\u964d&#xff1b;<\/li>\n<li>\u5185\u5bb9\u611f\u77e5&#xff1a;\u8def\u7531\u662f\u6309\u5185\u5bb9\u52a8\u6001\u51b3\u5b9a\u7684&#xff08;\u76f8\u5173\u7684\u5730\u65b9\u624d\u8fde&#xff09;&#xff0c;\u6bd4\u56fa\u5b9a\u7a97\u53e3\/\u56fa\u5b9a\u6b65\u957f\u7684\u7a00\u758f\u6ce8\u610f\u529b\u66f4\u7075\u6d3b&#xff1b;<\/li>\n<li>\u5bf9\u9ad8\u5206\u8fa8\u7387\u53cb\u597d&#xff1a;\u533b\u5b66\u56fe\u50cf\u5206\u8fa8\u7387\u9ad8\u3001\u6709\u6548\u4fe1\u606f\u7a00\u758f&#xff0c;\u6b63\u597d\u5403\u8fd9\u4e2a\u7ea2\u5229\u3002<\/li>\n<\/ul>\n<p>\u5728\u5206\u5272\u91cc\u7684\u4f5c\u7528&#xff1a;\u628a\u7f16\u7801\u5668\u91cc\u7684\u5168\u5c40\u6ce8\u610f\u529b\u6362\u6210 BRA&#xff0c;\u5728\u51e0\u4e4e\u4e0d\u6389\u7cbe\u5ea6\u7684\u60c5\u51b5\u4e0b\u5927\u5e45\u7701\u7b97\u529b\u548c\u663e\u5b58&#xff1b;\u5c24\u5176\u9002\u5408\u9ad8\u5206\u8fa8\u7387 2D \u533b\u5b66\u56fe\u50cf\u3001\u4ee5\u53ca\u591a\u5c3a\u5ea6\u7279\u5f81\u878d\u5408\u5904\u3002<\/p>\n<hr \/>\n<h3>\u56db\u3001\u5728 U-Net \u91cc\u7684\u63d2\u5165\u4f4d\u7f6e<\/h3>\n<p>BRA \u662f\u6ce8\u610f\u529b\u6a21\u5757&#xff0c;\u7528\u5728&#034;\u9700\u8981\u5168\u5c40\u5efa\u6a21&#034;\u7684\u4f4d\u7f6e&#xff1a;<\/p>\n<ul>\n<li>\u7f16\u7801\u5668\u6df1\u5c42 \/ \u74f6\u9888\u5c42&#xff1a;\u66ff\u6362 Self-Attention \u6216 Transformer block&#xff0c;\u505a\u957f\u8ddd\u79bb\u4f9d\u8d56&#xff1b;<\/li>\n<li>\u8df3\u8fde&#xff08;skip connection&#xff09;\u878d\u5408\u5904&#xff1a;\u5bf9\u591a\u5c3a\u5ea6\u7279\u5f81\u505a\u7a00\u758f\u5168\u5c40\u4ea4\u4e92&#xff1b;<\/li>\n<li>\u89e3\u7801\u5668\u4e0a\u91c7\u6837\u524d&#xff1a;\u5728\u4f4e\u5206\u8fa8\u7387\u3001\u9ad8\u901a\u9053\u5904\u6536\u76ca\u6700\u5927&#xff08;token \u5c11\u3001\u901a\u9053\u591a&#xff09;\u3002<\/li>\n<\/ul>\n<p>\u901a\u9053\u6570\u8d8a\u5927\u3001\u5206\u8fa8\u7387\u8d8a\u9ad8&#xff0c;BRA \u76f8\u5bf9\u5168\u6ce8\u610f\u529b\u7684\u4f18\u52bf\u8d8a\u660e\u663e\u3002<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u590d\u73b0\u4ee3\u7801&#xff08;PyTorch&#xff0c;\u9010\u884c\u4e2d\u6587\u6ce8\u91ca&#xff09;<\/h3>\n<p>\u4e0b\u9762\u662f\u7b80\u5316\u6559\u5b66\u7248&#xff0c;\u4fdd\u7559\u4e86 BRA \u7684\u4e24\u4e2a\u6838\u5fc3\u6b65\u9aa4&#xff08;\u533a\u57df\u8def\u7531 &#043; \u7a00\u758f\u6ce8\u610f\u529b&#xff09;&#xff0c;\u4ee3\u7801\u6e05\u6670\u3001\u53ef\u8dd1&#xff1b;\u751f\u4ea7\u4f7f\u7528\u5efa\u8bae\u5bf9\u7167\u5b98\u65b9\u5b9e\u73b0&#xff08;\u542b\u4f4d\u7f6e\u7f16\u7801\u3001\u4e0b\u91c7\u6837\u7b49\u7ec6\u8282&#xff09;\u3002<br \/>\nhttps:\/\/github.com\/rayleizhu\/BiFormer<\/p>\n<p><span class=\"token keyword\">import<\/span> torch<br \/>\n<span class=\"token keyword\">import<\/span> torch<span class=\"token punctuation\">.<\/span>nn <span class=\"token keyword\">as<\/span> nn<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">BiLevelRoutingAttention<\/span><span class=\"token punctuation\">(<\/span>nn<span class=\"token punctuation\">.<\/span>Module<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token triple-quoted-string string\">&#034;&#034;&#034;BiFormer \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b&#xff08;\u7b80\u5316\u6559\u5b66\u7248&#xff09;\u3002<br \/>\n    \u2460 \u533a\u57df\u7ea7\u8def\u7531&#xff1a;\u6bcf\u4e2a\u533a\u57df\u53ea\u4fdd\u7559\u6700\u76f8\u5173\u7684 topk \u4e2a\u533a\u57df&#xff1b;<br \/>\n    \u2461 \u533a\u57df\u7ea7 token-to-token \u6ce8\u610f\u529b&#xff1a;\u53ea\u5728\u9009\u4e2d\u7684\u533a\u57df\u91cc\u7b97\u6ce8\u610f\u529b\u3002<br \/>\n    &#034;&#034;&#034;<\/span><br \/>\n    <span class=\"token keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> dim<span class=\"token punctuation\">,<\/span> num_heads<span class=\"token operator\">&#061;<\/span><span class=\"token number\">8<\/span><span class=\"token punctuation\">,<\/span> n_win<span class=\"token operator\">&#061;<\/span><span class=\"token number\">7<\/span><span class=\"token punctuation\">,<\/span> topk<span class=\"token operator\">&#061;<\/span><span class=\"token number\">4<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token builtin\">super<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>__init__<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">assert<\/span> dim <span class=\"token operator\">%<\/span> num_heads <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;dim \u5fc5\u987b\u80fd\u88ab num_heads \u6574\u9664&#034;<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>dim <span class=\"token operator\">&#061;<\/span> dim<br \/>\n        self<span class=\"token punctuation\">.<\/span>num_heads <span class=\"token operator\">&#061;<\/span> num_heads<br \/>\n        self<span class=\"token punctuation\">.<\/span>n_win <span class=\"token operator\">&#061;<\/span> n_win                      <span class=\"token comment\"># \u628a\u7279\u5f81\u56fe\u5207\u6210 n_win \u00d7 n_win \u4e2a\u533a\u57df<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>topk <span class=\"token operator\">&#061;<\/span> topk                        <span class=\"token comment\"># \u6bcf\u4e2a\u533a\u57df\u53ea\u548c topk \u4e2a\u6700\u76f8\u5173\u533a\u57df\u505a\u6ce8\u610f\u529b<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>head_dim <span class=\"token operator\">&#061;<\/span> dim <span class=\"token operator\">\/\/<\/span> num_heads<br \/>\n        self<span class=\"token punctuation\">.<\/span>scale <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>head_dim <span class=\"token operator\">**<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">0.5<\/span>      <span class=\"token comment\"># \u7f29\u653e\u56e0\u5b50&#xff0c;\u9632\u6b62\u70b9\u79ef\u8fc7\u5927<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>qkv <span class=\"token operator\">&#061;<\/span> nn<span class=\"token punctuation\">.<\/span>Linear<span class=\"token punctuation\">(<\/span>dim<span class=\"token punctuation\">,<\/span> dim <span class=\"token operator\">*<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span>      <span class=\"token comment\"># \u4e00\u6b21\u6295\u5f71\u51fa q\/k\/v<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>proj <span class=\"token operator\">&#061;<\/span> nn<span class=\"token punctuation\">.<\/span>Linear<span class=\"token punctuation\">(<\/span>dim<span class=\"token punctuation\">,<\/span> dim<span class=\"token punctuation\">)<\/span>         <span class=\"token comment\"># \u8f93\u51fa\u6295\u5f71<\/span><br \/>\n        <span class=\"token comment\"># \u6df1\u5ea6\u5377\u79ef\u505a\u5c40\u90e8\u4f4d\u7f6e\u7f16\u7801&#xff08;LePE&#xff09;&#xff0c;\u8865\u56de\u88ab\u7a00\u758f\u5316\u4e22\u5931\u7684\u5c40\u90e8\u4fe1\u606f<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>lepe <span class=\"token operator\">&#061;<\/span> nn<span class=\"token punctuation\">.<\/span>Conv2d<span class=\"token punctuation\">(<\/span>dim<span class=\"token punctuation\">,<\/span> dim<span class=\"token punctuation\">,<\/span> kernel_size<span class=\"token operator\">&#061;<\/span><span class=\"token number\">5<\/span><span class=\"token punctuation\">,<\/span> padding<span class=\"token operator\">&#061;<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> groups<span class=\"token operator\">&#061;<\/span>dim<span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token keyword\">def<\/span> <span class=\"token function\">forward<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> x<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        B<span class=\"token punctuation\">,<\/span> N<span class=\"token punctuation\">,<\/span> C <span class=\"token operator\">&#061;<\/span> x<span class=\"token punctuation\">.<\/span>shape<br \/>\n        H <span class=\"token operator\">&#061;<\/span> W <span class=\"token operator\">&#061;<\/span> <span class=\"token builtin\">int<\/span><span class=\"token punctuation\">(<\/span>N <span class=\"token operator\">**<\/span> <span class=\"token number\">0.5<\/span><span class=\"token punctuation\">)<\/span>                   <span class=\"token comment\"># \u5047\u8bbe\u65b9\u5f62\u7279\u5f81\u56fe<\/span><br \/>\n        n <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>n_win<br \/>\n        rs <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>H <span class=\"token operator\">\/\/<\/span> n<span class=\"token punctuation\">)<\/span> <span class=\"token operator\">*<\/span> <span class=\"token punctuation\">(<\/span>W <span class=\"token operator\">\/\/<\/span> n<span class=\"token punctuation\">)<\/span>                <span class=\"token comment\"># \u6bcf\u4e2a\u533a\u57df\u5185\u7684 token \u6570<\/span><\/p>\n<p>        <span class=\"token comment\"># \u2460 \u751f\u6210 q\/k\/v&#xff1a;[B, heads, N, head_dim]<\/span><br \/>\n        qkv <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>qkv<span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>reshape<span class=\"token punctuation\">(<\/span>B<span class=\"token punctuation\">,<\/span> N<span class=\"token punctuation\">,<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> self<span class=\"token punctuation\">.<\/span>num_heads<span class=\"token punctuation\">,<\/span> self<span class=\"token punctuation\">.<\/span>head_dim<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>permute<span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">4<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        q<span class=\"token punctuation\">,<\/span> k<span class=\"token punctuation\">,<\/span> v <span class=\"token operator\">&#061;<\/span> qkv<span class=\"token punctuation\">[<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> qkv<span class=\"token punctuation\">[<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> qkv<span class=\"token punctuation\">[<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">]<\/span><\/p>\n<p>        <span class=\"token comment\"># \u2461 \u6309\u533a\u57df\u91cd\u5851&#xff1a;[B, heads, R, rs, head_dim]&#xff0c;R &#061; n*n \u4e2a\u533a\u57df<\/span><br \/>\n        <span class=\"token keyword\">def<\/span> <span class=\"token function\">to_region<\/span><span class=\"token punctuation\">(<\/span>t<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> t<span class=\"token punctuation\">.<\/span>reshape<span class=\"token punctuation\">(<\/span>B<span class=\"token punctuation\">,<\/span> self<span class=\"token punctuation\">.<\/span>num_heads<span class=\"token punctuation\">,<\/span> n <span class=\"token operator\">*<\/span> n<span class=\"token punctuation\">,<\/span> rs<span class=\"token punctuation\">,<\/span> self<span class=\"token punctuation\">.<\/span>head_dim<span class=\"token punctuation\">)<\/span><br \/>\n        q_r<span class=\"token punctuation\">,<\/span> k_r<span class=\"token punctuation\">,<\/span> v_r <span class=\"token operator\">&#061;<\/span> to_region<span class=\"token punctuation\">(<\/span>q<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> to_region<span class=\"token punctuation\">(<\/span>k<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> to_region<span class=\"token punctuation\">(<\/span>v<span class=\"token punctuation\">)<\/span><\/p>\n<p>        <span class=\"token comment\"># \u2462 \u533a\u57df&#034;\u4ee3\u8868\u5411\u91cf&#034; &#061; \u533a\u57df\u5185 token \u5e73\u5747&#xff0c;\u7528\u6765\u7b97\u533a\u57df\u95f4\u76f8\u5173\u5ea6<\/span><br \/>\n        q_rep <span class=\"token operator\">&#061;<\/span> q_r<span class=\"token punctuation\">.<\/span>mean<span class=\"token punctuation\">(<\/span>dim<span class=\"token operator\">&#061;<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span>                 <span class=\"token comment\"># [B, heads, R, head_dim]<\/span><br \/>\n        k_rep <span class=\"token operator\">&#061;<\/span> k_r<span class=\"token punctuation\">.<\/span>mean<span class=\"token punctuation\">(<\/span>dim<span class=\"token operator\">&#061;<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span>                 <span class=\"token comment\"># [B, heads, R, head_dim]<\/span><br \/>\n        aff <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>q_rep <span class=\"token operator\">*<\/span> self<span class=\"token punctuation\">.<\/span>scale<span class=\"token punctuation\">)<\/span> &#064; k_rep<span class=\"token punctuation\">.<\/span>transpose<span class=\"token punctuation\">(<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span>   <span class=\"token comment\"># [B, heads, R, R] \u533a\u57df\u76f8\u5173\u5ea6<\/span><\/p>\n<p>        <span class=\"token comment\"># \u2463 \u53cc\u5c42\u8def\u7531\u7684\u5173\u952e&#xff1a;\u6bcf\u4e2a\u533a\u57df\u53ea\u7559 topk \u4e2a\u6700\u76f8\u5173\u533a\u57df<\/span><br \/>\n        topk <span class=\"token operator\">&#061;<\/span> <span class=\"token builtin\">min<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">.<\/span>topk<span class=\"token punctuation\">,<\/span> n <span class=\"token operator\">*<\/span> n<span class=\"token punctuation\">)<\/span><br \/>\n        idx <span class=\"token operator\">&#061;<\/span> aff<span class=\"token punctuation\">.<\/span>topk<span class=\"token punctuation\">(<\/span>topk<span class=\"token punctuation\">,<\/span> dim<span class=\"token operator\">&#061;<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>indices    <span class=\"token comment\"># [B, heads, R, topk]<\/span><\/p>\n<p>        <span class=\"token comment\"># \u2464 \u6309\u8def\u7531\u7d22\u5f15&#xff0c;\u628a\u9009\u4e2d\u7684 k\/v \u533a\u57df\u805a\u8d77\u6765&#xff1a;[B, heads, R, topk, rs, head_dim]<\/span><br \/>\n        <span class=\"token keyword\">def<\/span> <span class=\"token function\">gather_region<\/span><span class=\"token punctuation\">(<\/span>t<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            d <span class=\"token operator\">&#061;<\/span> t<span class=\"token punctuation\">.<\/span>shape<span class=\"token punctuation\">[<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">]<\/span><br \/>\n            t_exp <span class=\"token operator\">&#061;<\/span> t<span class=\"token punctuation\">.<\/span>unsqueeze<span class=\"token punctuation\">(<\/span><span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>expand<span class=\"token punctuation\">(<\/span>B<span class=\"token punctuation\">,<\/span> self<span class=\"token punctuation\">.<\/span>num_heads<span class=\"token punctuation\">,<\/span> n <span class=\"token operator\">*<\/span> n<span class=\"token punctuation\">,<\/span> topk<span class=\"token punctuation\">,<\/span> rs<span class=\"token punctuation\">,<\/span> d<span class=\"token punctuation\">)<\/span><br \/>\n            index <span class=\"token operator\">&#061;<\/span> idx<span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">.<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token boolean\">None<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token boolean\">None<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">.<\/span>expand<span class=\"token punctuation\">(<\/span>B<span class=\"token punctuation\">,<\/span> self<span class=\"token punctuation\">.<\/span>num_heads<span class=\"token punctuation\">,<\/span> n <span class=\"token operator\">*<\/span> n<span class=\"token punctuation\">,<\/span> topk<span class=\"token punctuation\">,<\/span> rs<span class=\"token punctuation\">,<\/span> d<span class=\"token punctuation\">)<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> torch<span class=\"token punctuation\">.<\/span>gather<span class=\"token punctuation\">(<\/span>t_exp<span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> index<span class=\"token punctuation\">)<\/span><br \/>\n        k_g <span class=\"token operator\">&#061;<\/span> gather_region<span class=\"token punctuation\">(<\/span>k_r<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>reshape<span class=\"token punctuation\">(<\/span>B<span class=\"token punctuation\">,<\/span> self<span class=\"token punctuation\">.<\/span>num_heads<span class=\"token punctuation\">,<\/span> n <span class=\"token operator\">*<\/span> n<span class=\"token punctuation\">,<\/span> topk <span class=\"token operator\">*<\/span> rs<span class=\"token punctuation\">,<\/span> self<span class=\"token punctuation\">.<\/span>head_dim<span class=\"token punctuation\">)<\/span><br \/>\n        v_g <span class=\"token operator\">&#061;<\/span> gather_region<span class=\"token punctuation\">(<\/span>v_r<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>reshape<span class=\"token punctuation\">(<\/span>B<span class=\"token punctuation\">,<\/span> self<span class=\"token punctuation\">.<\/span>num_heads<span class=\"token punctuation\">,<\/span> n <span class=\"token operator\">*<\/span> n<span class=\"token punctuation\">,<\/span> topk <span class=\"token operator\">*<\/span> rs<span class=\"token punctuation\">,<\/span> self<span class=\"token punctuation\">.<\/span>head_dim<span class=\"token punctuation\">)<\/span><\/p>\n<p>        <span class=\"token comment\"># \u2465 \u53ea\u5728&#034;\u672c\u533a\u57df token \u00d7 \u9009\u4e2d\u533a\u57df key&#034;\u4e4b\u95f4\u505a\u6ce8\u610f\u529b<\/span><br \/>\n        attn <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">(<\/span>q_r <span class=\"token operator\">*<\/span> self<span class=\"token punctuation\">.<\/span>scale<span class=\"token punctuation\">)<\/span> &#064; k_g<span class=\"token punctuation\">.<\/span>transpose<span class=\"token punctuation\">(<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span>          <span class=\"token comment\"># [B, heads, R, rs, topk*rs]<\/span><br \/>\n        attn <span class=\"token operator\">&#061;<\/span> attn<span class=\"token punctuation\">.<\/span>softmax<span class=\"token punctuation\">(<\/span>dim<span class=\"token operator\">&#061;<\/span><span class=\"token operator\">&#8211;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        out <span class=\"token operator\">&#061;<\/span> attn &#064; v_g                                            <span class=\"token comment\"># [B, heads, R, rs, head_dim]<\/span><\/p>\n<p>        <span class=\"token comment\"># \u2466 \u8fd8\u539f\u56de token \u5e8f\u5217&#xff1a;[B, N, C]<\/span><br \/>\n        out <span class=\"token operator\">&#061;<\/span> out<span class=\"token punctuation\">.<\/span>reshape<span class=\"token punctuation\">(<\/span>B<span class=\"token punctuation\">,<\/span> self<span class=\"token punctuation\">.<\/span>num_heads<span class=\"token punctuation\">,<\/span> N<span class=\"token punctuation\">,<\/span> self<span class=\"token punctuation\">.<\/span>head_dim<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>permute<span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">3<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>reshape<span class=\"token punctuation\">(<\/span>B<span class=\"token punctuation\">,<\/span> N<span class=\"token punctuation\">,<\/span> C<span class=\"token punctuation\">)<\/span><\/p>\n<p>        <span class=\"token comment\"># \u2467 \u52a0\u5c40\u90e8\u4f4d\u7f6e\u7f16\u7801&#xff08;LePE&#xff09;&#043; \u8f93\u51fa\u6295\u5f71<\/span><br \/>\n        img <span class=\"token operator\">&#061;<\/span> out<span class=\"token punctuation\">.<\/span>transpose<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>reshape<span class=\"token punctuation\">(<\/span>B<span class=\"token punctuation\">,<\/span> C<span class=\"token punctuation\">,<\/span> H<span class=\"token punctuation\">,<\/span> W<span class=\"token punctuation\">)<\/span>              <span class=\"token comment\"># [B, C, H, W]<\/span><br \/>\n        img <span class=\"token operator\">&#061;<\/span> img <span class=\"token operator\">&#043;<\/span> self<span class=\"token punctuation\">.<\/span>lepe<span class=\"token punctuation\">(<\/span>img<span class=\"token punctuation\">)<\/span>                                  <span class=\"token comment\"># \u8865\u5c40\u90e8\u4f4d\u7f6e\u4fe1\u606f<\/span><br \/>\n        out <span class=\"token operator\">&#061;<\/span> img<span class=\"token punctuation\">.<\/span>flatten<span class=\"token punctuation\">(<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>transpose<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span>                        <span class=\"token comment\"># [B, N, C]<\/span><br \/>\n        out <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>proj<span class=\"token punctuation\">(<\/span>out<span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> out<\/p>\n<hr \/>\n<h3>\u516d\u3001\u63d2\u5165\u793a\u4f8b&#xff08;\u51e0\u884c\u585e\u8fdb\u4f60\u7684\u7f51\u7edc&#xff09;<\/h3>\n<p><span class=\"token comment\"># \u4f8b&#xff1a;\u7528 BRA \u66ff\u6362 U-Net \u74f6\u9888\u5c42\u7684\u5168\u5c40\u6ce8\u610f\u529b<\/span><br \/>\nself<span class=\"token punctuation\">.<\/span>attn <span class=\"token operator\">&#061;<\/span> BiLevelRoutingAttention<span class=\"token punctuation\">(<\/span>dim<span class=\"token operator\">&#061;<\/span><span class=\"token number\">256<\/span><span class=\"token punctuation\">,<\/span> num_heads<span class=\"token operator\">&#061;<\/span><span class=\"token number\">8<\/span><span class=\"token punctuation\">,<\/span> n_win<span class=\"token operator\">&#061;<\/span><span class=\"token number\">7<\/span><span class=\"token punctuation\">,<\/span> topk<span class=\"token operator\">&#061;<\/span><span class=\"token number\">4<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">forward<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> x<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span>              <span class=\"token comment\"># x: [B, N, C]<\/span><br \/>\n    x <span class=\"token operator\">&#061;<\/span> x <span class=\"token operator\">&#043;<\/span> self<span class=\"token punctuation\">.<\/span>attn<span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">)<\/span>           <span class=\"token comment\"># \u6b8b\u5dee\u63a5\u4f4f&#xff0c;\u66ff\u6362\u539f\u6765\u7684 SelfAttention \/ TransformerBlock<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> x<\/p>\n<hr \/>\n<h3>\u4e03\u3001\u5b9e\u6d4b\u7ecf\u9a8c\u4e0e\u6ce8\u610f\u70b9<\/h3>\n<ul>\n<li>\u7c92\u5ea6\u53ef\u8c03&#xff1a;n_win&#xff08;\u533a\u57df\u5212\u5206&#xff09;\u548c topk&#xff08;\u6bcf\u533a\u57df\u8fde\u51e0\u4e2a&#xff09;\u662f\u4e24\u4e2a\u6838\u5fc3\u65cb\u94ae\u2014\u2014topk \u8d8a\u5c0f\u8d8a\u7701&#xff0c;\u7cbe\u5ea6\u9760&#034;\u76f8\u5173\u6027&#034;\u4fdd\u4f4f&#xff1b;\u4e00\u822c n_win&#061;7\/14\u3001topk&#061;4 \u662f\u5e38\u7528\u8d77\u70b9\u3002<\/li>\n<li>\u590d\u6742\u5ea6&#xff1a;\u76f8\u5bf9\u5168\u5c40\u6ce8\u610f\u529b\u4ece&#034;\u968f token \u6570\u5e73\u65b9\u589e\u957f&#034;\u964d\u4e3a&#034;\u968f\u533a\u57df\u6570\u00d7topk \u589e\u957f&#034;&#xff0c;\u9ad8\u5206\u8fa8\u7387\u4e0b\u7701\u5f97\u6700\u591a\u3002<\/li>\n<li>\u8e29\u5751&#xff1a;\n<li>\u8f93\u5165\u5fc5\u987b\u662f\u65b9\u5f62\u7279\u5f81\u56fe&#xff08;H&#061;W&#xff09;&#xff0c;\u5426\u5219\u8981\u5904\u7406\u7684\u533a\u57df\u5207\u5206\u548c\u8fd8\u539f\u4f1a\u53d8\u5f62&#xff08;\u539f\u59cb\u5b9e\u73b0\u91cc\u7528 H\/\/n\u3001W\/\/n \u5206\u522b\u7b97&#xff09;&#xff1b;<\/li>\n<li>dim % num_heads &#061;&#061; 0\u3001H % n_win &#061;&#061; 0 \u90fd\u8981\u6210\u7acb&#xff0c;\u5426\u5219 reshape \u62a5\u9519&#xff1b;<\/li>\n<li>\u7a00\u758f\u5316\u4f1a\u4e22\u5c40\u90e8\u4fe1\u606f&#xff0c;\u52a1\u5fc5\u4fdd\u7559 LePE \u4e4b\u7c7b\u7684\u5c40\u90e8\u4f4d\u7f6e\u7f16\u7801&#xff1b;<\/li>\n<li>\u6559\u5b66\u7248\u505a\u4e86\u7b80\u5316&#xff0c;\u4e0a\u751f\u4ea7\u8bf7\u5bf9\u7167\u5b98\u65b9\u5b9e\u73b0&#xff08;\u542b kv \u4e0b\u91c7\u6837\u3001\u4f4d\u7f6e\u7f16\u7801\u7ec6\u8282&#xff09;\u3002<\/li>\n<\/li>\n<li>\u533b\u5b66\u5206\u5272\u573a\u666f&#xff1a;\u9ad8\u5206\u8fa8\u7387\u5207\u7247\u3001\u9700\u8981\u957f\u8ddd\u79bb\u4f9d\u8d56\u53c8\u8981\u63a7\u663e\u5b58\u65f6&#xff0c;BRA \u6bd4\u5168\u6ce8\u610f\u529b\u66f4\u5408\u9002&#xff1b;\u5c0f\u6570\u636e\u96c6\u4e0a\u5efa\u8bae\u914d\u5408\u9884\u8bad\u7ec3\u6216\u5f3a\u589e\u5e7f\u3002<\/li>\n<\/ul>\n<hr \/>\n<h3>\u516b\u3001\u5b8c\u6574\u5de5\u7a0b &amp; \u9886\u53d6<\/h3>\n<p>\u672c\u6587\u7684\u5b8c\u6574\u53ef\u8fd0\u884c\u5de5\u7a0b&#xff08;BRA \u7684 .py\u3001U-Net \u63d2\u5165 demo\u3001n_win\/topk \u53ef\u8c03\u914d\u7f6e\u3001\u9010\u884c\u4e2d\u6587\u6ce8\u91ca&#xff09;\u6211\u6574\u7406\u597d\u4e86\u3002<\/p>\n<p>\u9886\u53d6\u65b9\u5f0f&#xff1a;\u5173\u6ce8\u516cZHU\u53f7 MediVision&#xff0c;\u56de\u590d\u300c\u6a21\u5757\u300d\u2014\u2014\u81ea\u52a8\u628a\u300a\u5373\u63d2\u5373\u7528\u6a21\u5757\u5408\u96c6&#xff08;\u542b FasterNet \/ BiFormer \/ StarNet \/ RepViT \/ TransNeXt\u2026&#xff0c;\u7edf\u4e00\u63a5\u53e3&#xff0c;\u4e00\u6761 import \u5c31\u80fd\u7528&#xff09;\u300b\u7684\u5165\u53e3\u53d1\u7ed9\u4f60&#xff0c;\u8fdb\u7fa4\u514d\u8d39\u9886\u3002<\/p>\n<p>\u4e0b\u4e00\u7bc7\u9884\u544a&#xff1a;RepViT&#xff08;CVPR 2024&#xff09;\u2014\u2014\u628a ViT \u7684\u9ad8\u6548\u8bbe\u8ba1&#034;\u642c\u56de&#034;\u7eaf\u5377\u79ef&#xff0c;\u7528\u91cd\u53c2\u6570\u5316\u6362\u4e00\u4e2a\u53c8\u5feb\u53c8\u5f3a\u7684\u8f7b\u91cf\u4e3b\u5e72\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3010\u533b\u5b66\u56fe\u50cf\u5206\u5272\u6a21\u5757\u3011BiFormer \/ \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b&#xff08;CVPR 2023&#xff09;\u2014\u2014 \u53ea\u7b97\\&#8221;\u8be5\u7b97\u7684\u5730\u65b9\\&#8221;\u7684\u7a00\u758f\u6ce8\u610f\u529b<br \/>\n\u533b\u5b66\u56fe\u50cf\u5206\u5272\u91cc\u5230\u5904\u662f\u9ad8\u5206\u8fa8\u7387\u7279\u5f81\u56fe\u3002\u76f4\u63a5\u4e0a\u5168\u5c40\u6ce8\u610f\u529b&#xff08;Self-Attention&#xff09;\u6709\u4e24\u4e2a\u8001\u95ee\u9898&#xff1a;\u4e00\u662f\u8ba1\u7b97\u91cf\u968f token \u6570\u5e73\u65b9\u7ea7\u7206\u70b8&#xff1b;\u4e8c\u662f\u5927\u90e8\u5206\u533a\u57df\u5176\u5b9e\u6beb\u65e0\u5173\u7cfb&#xff08;\u6bd4\u5982\u80bf\u7624\u533a\u548c\u80cc\u666f\u533a&#xff09;&#xff0c;\u5374\u8981\u4e24\u4e24\u7b97\u4e00\u904d\u2014\u2014\u53c8\u6162\u53c8\u6d6a\u8d39\u3002<br \/>\nBiFormer&amp;<\/p>\n","protected":false},"author":2,"featured_media":112756,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[81,152,50,207,86],"topic":[],"class_list":["post-112757","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-python","tag-pytorch","tag-50","tag-207","tag-86"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u533b\u5b66\u56fe\u50cf\u5206\u5272\u6a21\u5757\u3011BiFormer \/ \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b\uff08CVPR 2023\uff09\u2014\u2014\u53ea\u7b97\u201c\u8be5\u7b97\u7684\u5730\u65b9\u201c\u7684\u7a00\u758f\u6ce8\u610f\u529b - \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\/112757.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010\u533b\u5b66\u56fe\u50cf\u5206\u5272\u6a21\u5757\u3011BiFormer \/ \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b\uff08CVPR 2023\uff09\u2014\u2014\u53ea\u7b97\u201c\u8be5\u7b97\u7684\u5730\u65b9\u201c\u7684\u7a00\u758f\u6ce8\u610f\u529b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u3010\u533b\u5b66\u56fe\u50cf\u5206\u5272\u6a21\u5757\u3011BiFormer \/ \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b&#xff08;CVPR 2023&#xff09;\u2014\u2014 \u53ea\u7b97&quot;\u8be5\u7b97\u7684\u5730\u65b9&quot;\u7684\u7a00\u758f\u6ce8\u610f\u529b \u533b\u5b66\u56fe\u50cf\u5206\u5272\u91cc\u5230\u5904\u662f\u9ad8\u5206\u8fa8\u7387\u7279\u5f81\u56fe\u3002\u76f4\u63a5\u4e0a\u5168\u5c40\u6ce8\u610f\u529b&#xff08;Self-Attention&#xff09;\u6709\u4e24\u4e2a\u8001\u95ee\u9898&#xff1a;\u4e00\u662f\u8ba1\u7b97\u91cf\u968f token \u6570\u5e73\u65b9\u7ea7\u7206\u70b8&#xff1b;\u4e8c\u662f\u5927\u90e8\u5206\u533a\u57df\u5176\u5b9e\u6beb\u65e0\u5173\u7cfb&#xff08;\u6bd4\u5982\u80bf\u7624\u533a\u548c\u80cc\u666f\u533a&#xff09;&#xff0c;\u5374\u8981\u4e24\u4e24\u7b97\u4e00\u904d\u2014\u2014\u53c8\u6162\u53c8\u6d6a\u8d39\u3002 BiFormer&amp;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/112757.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-04T12:17:24+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261004121723-6ac243d343fc4.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=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/112757.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/112757.html\",\"name\":\"\u3010\u533b\u5b66\u56fe\u50cf\u5206\u5272\u6a21\u5757\u3011BiFormer \/ \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b\uff08CVPR 2023\uff09\u2014\u2014\u53ea\u7b97\u201c\u8be5\u7b97\u7684\u5730\u65b9\u201c\u7684\u7a00\u758f\u6ce8\u610f\u529b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-10-04T12:17:24+00:00\",\"dateModified\":\"2026-10-04T12:17:24+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/112757.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/112757.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/112757.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u533b\u5b66\u56fe\u50cf\u5206\u5272\u6a21\u5757\u3011BiFormer \/ \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b\uff08CVPR 2023\uff09\u2014\u2014\u53ea\u7b97\u201c\u8be5\u7b97\u7684\u5730\u65b9\u201c\u7684\u7a00\u758f\u6ce8\u610f\u529b\"}]},{\"@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\u533b\u5b66\u56fe\u50cf\u5206\u5272\u6a21\u5757\u3011BiFormer \/ \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b\uff08CVPR 2023\uff09\u2014\u2014\u53ea\u7b97\u201c\u8be5\u7b97\u7684\u5730\u65b9\u201c\u7684\u7a00\u758f\u6ce8\u610f\u529b - \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\/112757.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010\u533b\u5b66\u56fe\u50cf\u5206\u5272\u6a21\u5757\u3011BiFormer \/ \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b\uff08CVPR 2023\uff09\u2014\u2014\u53ea\u7b97\u201c\u8be5\u7b97\u7684\u5730\u65b9\u201c\u7684\u7a00\u758f\u6ce8\u610f\u529b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u3010\u533b\u5b66\u56fe\u50cf\u5206\u5272\u6a21\u5757\u3011BiFormer \/ \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b&#xff08;CVPR 2023&#xff09;\u2014\u2014 \u53ea\u7b97\"\u8be5\u7b97\u7684\u5730\u65b9\"\u7684\u7a00\u758f\u6ce8\u610f\u529b \u533b\u5b66\u56fe\u50cf\u5206\u5272\u91cc\u5230\u5904\u662f\u9ad8\u5206\u8fa8\u7387\u7279\u5f81\u56fe\u3002\u76f4\u63a5\u4e0a\u5168\u5c40\u6ce8\u610f\u529b&#xff08;Self-Attention&#xff09;\u6709\u4e24\u4e2a\u8001\u95ee\u9898&#xff1a;\u4e00\u662f\u8ba1\u7b97\u91cf\u968f token \u6570\u5e73\u65b9\u7ea7\u7206\u70b8&#xff1b;\u4e8c\u662f\u5927\u90e8\u5206\u533a\u57df\u5176\u5b9e\u6beb\u65e0\u5173\u7cfb&#xff08;\u6bd4\u5982\u80bf\u7624\u533a\u548c\u80cc\u666f\u533a&#xff09;&#xff0c;\u5374\u8981\u4e24\u4e24\u7b97\u4e00\u904d\u2014\u2014\u53c8\u6162\u53c8\u6d6a\u8d39\u3002 BiFormer&amp;","og_url":"https:\/\/www.wsisp.com\/helps\/112757.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-10-04T12:17:24+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/10\/20261004121723-6ac243d343fc4.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/112757.html","url":"https:\/\/www.wsisp.com\/helps\/112757.html","name":"\u3010\u533b\u5b66\u56fe\u50cf\u5206\u5272\u6a21\u5757\u3011BiFormer \/ \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b\uff08CVPR 2023\uff09\u2014\u2014\u53ea\u7b97\u201c\u8be5\u7b97\u7684\u5730\u65b9\u201c\u7684\u7a00\u758f\u6ce8\u610f\u529b - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-10-04T12:17:24+00:00","dateModified":"2026-10-04T12:17:24+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/112757.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/112757.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/112757.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010\u533b\u5b66\u56fe\u50cf\u5206\u5272\u6a21\u5757\u3011BiFormer \/ \u53cc\u5c42\u8def\u7531\u6ce8\u610f\u529b\uff08CVPR 2023\uff09\u2014\u2014\u53ea\u7b97\u201c\u8be5\u7b97\u7684\u5730\u65b9\u201c\u7684\u7a00\u758f\u6ce8\u610f\u529b"}]},{"@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\/112757","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=112757"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/112757\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/112756"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=112757"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=112757"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=112757"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=112757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}