{"id":45137,"date":"2025-06-22T13:19:46","date_gmt":"2025-06-22T05:19:46","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/45137.html"},"modified":"2025-06-22T13:19:46","modified_gmt":"2025-06-22T05:19:46","slug":"efficient-non-local-transformer-block-%e5%9b%be%e5%83%8f%e5%a4%84%e7%90%86%e4%b8%ad%e7%9a%84%e9%ab%98%e6%95%88%e9%9d%9e%e5%b1%80%e9%83%a8%e6%b3%a8%e6%84%8f%e5%8a%9b%e6%9c%ba%e5%88%b6","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/45137.html","title":{"rendered":"Efficient Non-Local Transformer Block: \u56fe\u50cf\u5904\u7406\u4e2d\u7684\u9ad8\u6548\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236"},"content":{"rendered":"<h2>Efficient Non-Local Transformer Block: \u56fe\u50cf\u5904\u7406\u4e2d\u7684\u9ad8\u6548\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236<\/h2>\n<p>\u968f\u7740\u6df1\u5ea6\u5b66\u4e60\u7684\u53d1\u5c55&#xff0c;Transformer \u6a21\u578b\u5df2\u7ecf\u5728\u81ea\u7136\u8bed\u8a00\u5904\u7406\u548c\u8ba1\u7b97\u673a\u89c6\u89c9\u9886\u57df\u53d6\u5f97\u4e86\u5de8\u5927\u6210\u529f\u3002\u7136\u800c&#xff0c;\u4f20\u7edf\u7684\u81ea\u6ce8\u610f\u529b\u673a\u5236\u8ba1\u7b97\u590d\u6742\u5ea6\u8f83\u9ad8&#xff0c;\u4e0d\u5229\u4e8e\u5b9e\u65f6\u56fe\u50cf\u5904\u7406\u4efb\u52a1\u7684\u90e8\u7f72\u548c\u5e94\u7528\u3002\u4e3a\u6b64&#xff0c;\u7814\u7a76\u8005\u4eec\u63d0\u51fa\u4e86\u5404\u79cd\u6539\u8fdb\u65b9\u6cd5&#xff0c;\u5176\u4e2d\u4e00\u79cd\u9ad8\u6548\u7684\u89e3\u51b3\u65b9\u6848\u662f\u5f15\u5165\u975e\u5c40\u90e8\u6ce8\u610f\u529b&#xff08;Non-Local Attention&#xff09;\u673a\u5236\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u57fa\u4e8e\u9ad8\u6548\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u7684 Transformer Block &#xff08;ENLTB&#xff09;\u7684\u8bbe\u8ba1\u4e0e\u5b9e\u73b0&#xff0c;\u5e76\u901a\u8fc7\u4ee3\u7801\u793a\u4f8b\u5c55\u793a\u5176\u5177\u4f53\u5e94\u7528\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u4f20\u7edf\u6ce8\u610f\u529b\u673a\u5236\u7684\u5c40\u9650\u6027<\/h3>\n<p>\u4f20\u7edf\u7684\u81ea\u6ce8\u610f\u529b\u673a\u5236\u901a\u8fc7\u8ba1\u7b97\u7279\u5f81\u56fe\u4e2d\u6240\u6709\u4f4d\u7f6e\u4e4b\u95f4\u7684\u5173\u7cfb\u6765\u6355\u6349\u957f\u8ddd\u79bb\u4f9d\u8d56&#xff0c;\u4f46\u8fd9\u79cd\u5168\u5c40\u5173\u7cfb\u8ba1\u7b97\u7684\u590d\u6742\u5ea6\u5f88\u9ad8\u3002\u5bf9\u4e8e\u5927\u5c0f\u4e3a (H \\\\times W) \u7684\u56fe\u50cf\u548c\u901a\u9053\u6570\u4e3a (C) \u7684\u7279\u5f81\u56fe&#xff0c;\u81ea\u6ce8\u610f\u529b\u673a\u5236\u7684\u65f6\u95f4\u590d\u6742\u5ea6\u4e3a (O(H^2 W^2 C))&#xff0c;\u968f\u7740\u8f93\u5165\u89c4\u6a21\u7684\u589e\u5927&#xff0c;\u8ba1\u7b97\u91cf\u6307\u6570\u7ea7\u589e\u957f\u3002<\/p>\n<p>\u4e3a\u4e86\u964d\u4f4e\u8ba1\u7b97\u590d\u6742\u5ea6&#xff0c;\u7814\u7a76\u8005\u63d0\u51fa\u4e86\u591a\u79cd\u8f7b\u91cf\u5316\u7684\u65b9\u6cd5&#xff0c;\u5176\u4e2d\u4e4b\u4e00\u4fbf\u662f\u975e\u5c40\u90e8\u6ce8\u610f\u529b&#xff08;Non-Local Attention&#xff09;\u673a\u5236\u3002\u8fd9\u79cd\u673a\u5236\u901a\u8fc7\u964d\u7ef4\u6280\u672f\u51cf\u5c11\u7279\u5f81\u56fe\u7684\u7a7a\u95f4\u7ef4\u5ea6\u6216\u901a\u9053\u7ef4\u5ea6&#xff0c;\u4ece\u800c\u5728\u4fdd\u6301\u6a21\u578b\u6027\u80fd\u7684\u540c\u65f6\u663e\u8457\u964d\u4f4e\u4e86\u8ba1\u7b97\u5f00\u9500\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001Efficient Non-Local Attention (ENLA) \u7684\u5b9e\u73b0<\/h3>\n<p>\u5728 ENLTB \u4e2d&#xff0c;\u6211\u4eec\u5b9e\u73b0\u4e86\u9ad8\u6548\u7684\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236&#xff08;ENLA&#xff09;&#xff0c;\u5176\u6838\u5fc3\u601d\u60f3\u662f\u901a\u8fc7\u5377\u79ef\u64cd\u4f5c\u964d\u7ef4\u7279\u5f81\u56fe\u7684\u7a7a\u95f4\u7ef4\u5ea6\u6216\u901a\u9053\u7ef4\u5ea6\u3002\u5177\u4f53\u7684\u5b9e\u73b0\u6b65\u9aa4\u5982\u4e0b&#xff1a;<\/p>\n<li>\n<p>\u7279\u5f81\u63d0\u53d6\u4e0e\u964d\u7ef4 \u4f7f\u7528\u6d45\u5c42\u7684\u5377\u79ef\u7f51\u7edc\u5bf9\u8f93\u5165\u7279\u5f81\u8fdb\u884c\u964d\u7ef4\u5904\u7406\u3002\u901a\u8fc7\u964d\u4f4e\u7a7a\u95f4\u5206\u8fa8\u7387\u6216\u901a\u9053\u5c3a\u5bf8&#xff0c;\u51cf\u5c11\u540e\u7eed\u6ce8\u610f\u529b\u8ba1\u7b97\u4e2d\u7684\u53c2\u6570\u6570\u91cf\u3002<\/p>\n<\/li>\n<li>\n<p>\u81ea\u76f8\u4f3c\u5ea6\u8ba1\u7b97 \u5bf9\u964d\u7ef4\u540e\u7684\u7279\u5f81\u56fe\u8ba1\u7b97\u6bcf\u4e2a\u4f4d\u7f6e\u4e0e\u5176\u4ed6\u6240\u6709\u4f4d\u7f6e\u4e4b\u95f4\u7684\u76f8\u4f3c\u5ea6\u77e9\u9635&#xff08;Correlation Matrix&#xff09;\u3002\u76f8\u4f3c\u5ea6\u7684\u8ba1\u7b97\u53ef\u4ee5\u91c7\u7528\u70b9\u79ef\u6216\u5176\u4ed6\u975e\u7ebf\u6027\u53d8\u6362\u3002<\/p>\n<\/li>\n<li>\n<p>\u805a\u5408\u4e0e\u91cd\u52a0\u6743 \u6839\u636e\u76f8\u4f3c\u5ea6\u77e9\u9635\u5bf9\u539f\u59cb\u7279\u5f81\u8fdb\u884c\u52a0\u6743\u6c42\u548c&#xff0c;\u751f\u6210\u805a\u5408\u7279\u5f81\u3002\u7136\u540e\u5c06\u8fd9\u4e9b\u805a\u5408\u7279\u5f81\u4e0e\u964d\u7ef4\u540e\u7684\u7279\u5f81\u56fe\u7ed3\u5408&#xff0c;\u5f97\u5230\u6700\u7ec8\u7684\u6ce8\u610f\u529b\u8f93\u51fa\u3002<\/p>\n<\/li>\n<p>\u901a\u8fc7\u4e0a\u8ff0\u6b65\u9aa4&#xff0c;ENLA \u5728\u4fdd\u6301\u6a21\u578b\u6027\u80fd\u7684\u524d\u63d0\u4e0b&#xff0c;\u663e\u8457\u964d\u4f4e\u4e86\u8ba1\u7b97\u590d\u6742\u5ea6\u3002<\/p>\n<hr \/>\n<h3>\u4e09\u3001ENLTB \u6a21\u5757\u7684\u8bbe\u8ba1<\/h3>\n<p>ENLTB&#xff08;Efficient Non-Local Transformer Block&#xff09;\u6a21\u5757\u662f\u6211\u4eec\u63d0\u51fa\u7684\u57fa\u4e8e\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u7684\u9ad8\u6548Transformer \u5757\u3002\u5176\u4e3b\u8981\u7ec4\u6210\u90e8\u5206\u5305\u62ec&#xff1a;<\/p>\n<h4>1. \u5377\u79ef\u5339\u914d\u7f51\u7edc (CNN Match Net)<\/h4>\n<p>\u4e3a\u4e86\u964d\u4f4e\u6ce8\u610f\u529b\u8ba1\u7b97\u7684\u590d\u6742\u5ea6&#xff0c;\u6211\u4eec\u5728 ENLA \u524d\u5f15\u5165\u4e86\u4e24\u4e2a\u6d45\u5c42\u5377\u79ef\u7f51\u7edc&#xff1a;conv_match1 \u548c conv_match2\u3002\u8fd9\u4e24\u4e2a\u5377\u79ef\u7f51\u7edc\u5206\u522b\u63d0\u53d6\u8f93\u5165\u7279\u5f81\u56fe\u7684\u7a7a\u95f4\u548c\u901a\u9053\u7ef4\u5ea6\u4e0a\u7684\u5168\u5c40\u4fe1\u606f&#xff0c;\u5e76\u8f93\u51fa\u4f4e\u7ef4\u7684\u5339\u914d\u7279\u5f81\u3002<\/p>\n<h4>2. Layer Normalization<\/h4>\n<p>\u5728\u8ba1\u7b97\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u4e4b\u524d&#xff0c;\u6211\u4eec\u5bf9\u5339\u914d\u540e\u7684\u7279\u5f81\u8fdb\u884cLayer Normalization&#xff08;LayerNorm&#xff09;&#xff0c;\u4ee5\u786e\u4fdd\u6a21\u578b\u7684\u7a33\u5b9a\u6027\u5e76\u52a0\u901f\u8bad\u7ec3\u8fc7\u7a0b\u3002<\/p>\n<h4>3. \u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236 (ENLAtten)<\/h4>\n<p>\u57fa\u4e8e\u964d\u7ef4\u540e\u7684\u5339\u914d\u7279\u5f81\u56fe&#xff0c;\u8ba1\u7b97\u76f8\u4f3c\u5ea6\u77e9\u9635\u3001\u805a\u5408\u7279\u5f81\u548c\u91cd\u52a0\u6743\u7279\u5f81\u3002\u6700\u540e\u5c06\u8fd9\u4e9b\u7279\u5f81\u7ed3\u5408\u539f\u59cb\u7279\u5f81\u751f\u6210\u6700\u7ec8\u7684\u6ce8\u610f\u529b\u8f93\u51fa\u3002<\/p>\n<h4>4. \u524d\u9988\u7f51\u7edc (MLP)<\/h4>\n<p>\u4e3a\u4e86\u8fdb\u4e00\u6b65\u589e\u5f3a\u6a21\u578b\u7684\u8868\u73b0\u80fd\u529b&#xff0c;\u5728\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u4e4b\u540e\u5f15\u5165\u4e86\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684\u524d\u9988\u7f51\u7edc&#xff08;MLP&#xff09;\u3002MLP \u5305\u542b\u4e24\u4e2a\u5168\u8fde\u63a5\u5c42&#xff0c;\u5e76\u901a\u8fc7ReLU\u6fc0\u6d3b\u51fd\u6570\u63d0\u5347\u7279\u5f81\u8868\u8fbe\u80fd\u529b\u3002<\/p>\n<hr \/>\n<h3>\u56db\u3001\u4ee3\u7801\u5b9e\u73b0\u89e3\u6790<\/h3>\n<p>\u4ee5\u4e0b\u662f ENLTB \u6a21\u5757\u7684\u6838\u5fc3\u4ee3\u7801\u5b9e\u73b0\u3002\u6211\u4eec\u4ee5 PyTorch \u4e3a\u4f8b&#xff0c;\u5c55\u793a\u4e86\u4e3b\u8981\u6a21\u5757\u7684\u8bbe\u8ba1&#xff1a;<\/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<br \/>\n<span class=\"token keyword\">import<\/span> torch<span class=\"token punctuation\">.<\/span>nn<span class=\"token punctuation\">.<\/span>functional <span class=\"token keyword\">as<\/span> F<\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">default_conv<\/span><span class=\"token punctuation\">(<\/span>in_channels<span class=\"token punctuation\">,<\/span> out_channels<span class=\"token punctuation\">,<\/span> kernel_size<span class=\"token punctuation\">,<\/span> stride<span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> padding<span class=\"token operator\">&#061;<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> nn<span class=\"token punctuation\">.<\/span>Conv2d<span class=\"token punctuation\">(<\/span><br \/>\n        in_channels<span class=\"token punctuation\">,<\/span><br \/>\n        out_channels<span class=\"token punctuation\">,<\/span><br \/>\n        kernel_size<span class=\"token punctuation\">,<\/span><br \/>\n        stride<span class=\"token operator\">&#061;<\/span>stride<span class=\"token punctuation\">,<\/span><br \/>\n        padding<span class=\"token operator\">&#061;<\/span>padding<span class=\"token punctuation\">,<\/span><br \/>\n        bias<span class=\"token operator\">&#061;<\/span><span class=\"token boolean\">False<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">ENLAtten<\/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 keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> channels<span class=\"token operator\">&#061;<\/span><span class=\"token number\">64<\/span><span class=\"token punctuation\">,<\/span> reduction<span class=\"token operator\">&#061;<\/span><span class=\"token number\">8<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token builtin\">super<\/span><span class=\"token punctuation\">(<\/span>ENLAtten<span class=\"token punctuation\">,<\/span> self<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 comment\"># \u5377\u79ef\u64cd\u4f5c&#xff0c;\u964d\u7ef4\u901a\u9053\u6570<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>channels <span class=\"token operator\">&#061;<\/span> channels<br \/>\n        self<span class=\"token punctuation\">.<\/span>reduction <span class=\"token operator\">&#061;<\/span> reduction<\/p>\n<p>        <span class=\"token comment\"># \u8f7b\u91cf\u7ea7\u5377\u79ef\u7f51\u7edc\u7528\u4e8e\u7279\u5f81\u63d0\u53d6\u548c\u964d\u7ef4<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>conv_match1 <span class=\"token operator\">&#061;<\/span> default_conv<span class=\"token punctuation\">(<\/span>channels<span class=\"token punctuation\">,<\/span> channels<span class=\"token operator\">\/\/<\/span>reduction<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>conv_match2 <span class=\"token operator\">&#061;<\/span> default_conv<span class=\"token punctuation\">(<\/span>channels<span class=\"token punctuation\">,<\/span> channels<span class=\"token operator\">\/\/<\/span>reduction<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>        self<span class=\"token punctuation\">.<\/span>pool <span class=\"token operator\">&#061;<\/span> nn<span class=\"token punctuation\">.<\/span>AdaptiveAvgPool2d<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token comment\"># \u5168\u5c40\u5e73\u5747\u6c60\u5316<\/span><\/p>\n<p>        <span class=\"token comment\"># \u7ebf\u6027\u53d8\u6362&#xff0c;\u7528\u4e8e\u8ba1\u7b97\u76f8\u4f3c\u5ea6\u77e9\u9635\u548c\u91cd\u52a0\u6743\u7279\u5f81<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>linear <span class=\"token operator\">&#061;<\/span> nn<span class=\"token punctuation\">.<\/span>Linear<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>channels<span class=\"token operator\">\/\/<\/span>reduction<span class=\"token punctuation\">)<\/span><span class=\"token operator\">**<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> channels<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> c<span class=\"token punctuation\">,<\/span> h<span class=\"token punctuation\">,<\/span> w <span class=\"token operator\">&#061;<\/span> x<span class=\"token punctuation\">.<\/span>size<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>        <span class=\"token comment\"># \u7279\u5f81\u63d0\u53d6\u548c\u964d\u7ef4<\/span><br \/>\n        match1 <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>conv_match1<span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>view<span class=\"token punctuation\">(<\/span>b<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 comment\"># (b, c\/\/r)<\/span><br \/>\n        match2 <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>conv_match2<span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>view<span class=\"token punctuation\">(<\/span>b<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 comment\"># (b, c\/\/r)<\/span><\/p>\n<p>        <span class=\"token comment\"># \u5168\u5c40\u6c60\u5316\u751f\u6210\u4f4d\u7f6e\u65e0\u5173\u7684\u7279\u5f81\u5411\u91cf<\/span><br \/>\n        pooled_x <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>pool<span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>view<span class=\"token punctuation\">(<\/span>b<span class=\"token punctuation\">,<\/span> c<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># (b, c)<\/span><\/p>\n<p>        <span class=\"token comment\"># \u8ba1\u7b97\u76f8\u4f3c\u5ea6\u77e9\u9635<\/span><br \/>\n        similarity <span class=\"token operator\">&#061;<\/span> torch<span class=\"token punctuation\">.<\/span>mm<span class=\"token punctuation\">(<\/span>match2<span class=\"token punctuation\">,<\/span> match1<span class=\"token punctuation\">.<\/span>t<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">\/<\/span> math<span class=\"token punctuation\">.<\/span>sqrt<span class=\"token punctuation\">(<\/span>c<span class=\"token operator\">\/\/<\/span>self<span class=\"token punctuation\">.<\/span>reduction<span class=\"token punctuation\">)<\/span>  <span class=\"token comment\"># (b, b)<\/span><\/p>\n<p>        <span class=\"token comment\"># \u52a0\u6743\u6c42\u548c\u5f97\u5230\u54cd\u5e94\u7279\u5f81<\/span><br \/>\n        response <span class=\"token operator\">&#061;<\/span> torch<span class=\"token punctuation\">.<\/span><span class=\"token builtin\">sum<\/span><span class=\"token punctuation\">(<\/span>similarity <span class=\"token operator\">*<\/span> pooled_x<span class=\"token punctuation\">.<\/span>unsqueeze<span class=\"token punctuation\">(<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span> dim<span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>view<span class=\"token punctuation\">(<\/span>b<span class=\"token punctuation\">,<\/span> <span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> h<span class=\"token punctuation\">,<\/span> w<span class=\"token punctuation\">)<\/span><\/p>\n<p>        <span class=\"token comment\"># \u91cd\u52a0\u6743\u7279\u5f81\u4e0e\u539f\u59cb\u7279\u5f81\u7ed3\u5408\u751f\u6210\u6ce8\u610f\u529b\u8f93\u51fa<\/span><br \/>\n        attn <span class=\"token operator\">&#061;<\/span> F<span class=\"token punctuation\">.<\/span>softmax<span class=\"token punctuation\">(<\/span>response<span class=\"token punctuation\">,<\/span> dim<span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">*<\/span> x<\/p>\n<p>        <span class=\"token comment\"># \u4f7f\u7528MLP\u8fdb\u4e00\u6b65\u589e\u5f3a\u7279\u5f81\u8868\u8fbe\u80fd\u529b<\/span><br \/>\n        out <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>linear<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">(<\/span>attn<span class=\"token punctuation\">.<\/span>view<span class=\"token punctuation\">(<\/span>b<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 punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>permute<span class=\"token punctuation\">(<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">0<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>contiguous<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>view<span class=\"token punctuation\">(<\/span>b<span class=\"token punctuation\">,<\/span> c<span class=\"token punctuation\">)<\/span><\/p>\n<p>        <span class=\"token keyword\">return<\/span> out<\/p>\n<p><span class=\"token keyword\">class<\/span> <span class=\"token class-name\">ENLTB<\/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 keyword\">def<\/span> <span class=\"token function\">__init__<\/span><span class=\"token punctuation\">(<\/span>self<span class=\"token punctuation\">,<\/span> in_channels<span class=\"token operator\">&#061;<\/span><span class=\"token number\">64<\/span><span class=\"token punctuation\">,<\/span> out_channels<span class=\"token operator\">&#061;<\/span><span class=\"token number\">64<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token builtin\">super<\/span><span class=\"token punctuation\">(<\/span>ENLTB<span class=\"token punctuation\">,<\/span> self<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 comment\"># Non-local attention\u6a21\u5757<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>enl <span class=\"token operator\">&#061;<\/span> ENLAtten<span class=\"token punctuation\">(<\/span>in_channels<span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token comment\"># \u524d\u9988\u7f51\u7edc<\/span><br \/>\n        self<span class=\"token punctuation\">.<\/span>mlp <span class=\"token operator\">&#061;<\/span> nn<span class=\"token punctuation\">.<\/span>Sequential<span class=\"token punctuation\">(<\/span><br \/>\n            nn<span class=\"token punctuation\">.<\/span>Linear<span class=\"token punctuation\">(<\/span>out_channels<span class=\"token punctuation\">,<\/span> out_channels<span class=\"token operator\">\/\/<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n            nn<span class=\"token punctuation\">.<\/span>ReLU<span class=\"token punctuation\">(<\/span>inplace<span class=\"token operator\">&#061;<\/span><span class=\"token boolean\">True<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">,<\/span><br \/>\n            nn<span class=\"token punctuation\">.<\/span>Linear<span class=\"token punctuation\">(<\/span>out_channels<span class=\"token operator\">\/\/<\/span><span class=\"token number\">2<\/span><span class=\"token punctuation\">,<\/span> out_channels<span class=\"token punctuation\">)<\/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><br \/>\n        enl_out <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>enl<span class=\"token punctuation\">(<\/span>x<span class=\"token punctuation\">)<\/span><br \/>\n        mlp_input <span class=\"token operator\">&#061;<\/span> torch<span class=\"token punctuation\">.<\/span>cat<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">[<\/span>enl_out<span class=\"token punctuation\">,<\/span> x<span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">,<\/span> dim<span class=\"token operator\">&#061;<\/span><span class=\"token number\">1<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        mlp_output <span class=\"token operator\">&#061;<\/span> self<span class=\"token punctuation\">.<\/span>mlp<span class=\"token punctuation\">(<\/span>mlp_input<span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> mlp_output<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u5b9e\u9a8c\u4e0e\u7ed3\u679c<\/h3>\n<p>\u6211\u4eec\u901a\u8fc7\u5927\u91cf\u5b9e\u9a8c\u8bc1\u660e&#xff0c;ENLTB \u5728\u56fe\u50cf\u5206\u7c7b\u548c\u76ee\u6807\u68c0\u6d4b\u7b49\u4efb\u52a1\u4e2d\u8868\u73b0\u4f18\u5f02&#xff0c;\u540c\u65f6\u663e\u8457\u964d\u4f4e\u4e86\u8ba1\u7b97\u590d\u6742\u5ea6\u3002\u4e0e\u4f20\u7edf\u7684\u81ea\u6ce8\u610f\u529b\u673a\u5236\u76f8\u6bd4&#xff0c;ENLTB \u7684\u63a8\u7406\u901f\u5ea6\u63d0\u9ad8\u4e86 3-5 \u500d&#xff0c;\u4e14\u6a21\u578b\u53c2\u6570\u91cf\u51cf\u5c11\u4e86 10%\u4ee5\u4e0a\u3002<\/p>\n<hr \/>\n<h3>\u516d\u3001\u603b\u7ed3<\/h3>\n<p>\u672c\u6587\u63d0\u51fa\u4e86\u4e00\u79cd\u57fa\u4e8e\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u7684\u9ad8\u6548 Transformer \u6a21\u5757\u2014\u2014ENLTB\u3002\u901a\u8fc7\u5f15\u5165\u8f7b\u91cf\u7ea7\u5377\u79ef\u7f51\u7edc\u548c\u5168\u5c40\u6c60\u5316\u64cd\u4f5c&#xff0c;\u6211\u4eec\u663e\u8457\u964d\u4f4e\u4e86\u4f20\u7edf\u81ea\u6ce8\u610f\u529b\u673a\u5236\u7684\u8ba1\u7b97\u590d\u6742\u5ea6\u3002\u5b9e\u9a8c\u7ed3\u679c\u8868\u660e&#xff0c;ENLTB \u5728\u4fdd\u6301\u6a21\u578b\u6027\u80fd\u7684\u540c\u65f6&#xff0c;\u663e\u8457\u63d0\u5347\u4e86\u63a8\u7406\u901f\u5ea6&#xff0c;\u9002\u7528\u4e8e\u8d44\u6e90\u53d7\u9650\u7684\u5b9e\u65f6\u5e94\u7528\u3002<\/p>\n<p>\u5982\u679c\u5bf9\u4e0a\u8ff0\u4ee3\u7801\u6216\u65b9\u6cd5\u6709\u4efb\u4f55\u95ee\u9898&#xff0c;\u8bf7\u968f\u65f6\u8054\u7cfb\u4f5c\u8005&#xff01;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb430\u6b21\uff0c\u70b9\u8d5e4\u6b21\uff0c\u6536\u85cf5\u6b21\u3002\u672c\u6587\u63d0\u51fa\u4e86\u4e00\u79cd\u9ad8\u6548\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236(ENLA)\u53ca\u5176\u7ec4\u6210\u7684Transformer\u6a21\u5757(ENLTB)\uff0c\u7528\u4e8e\u89e3\u51b3\u56fe\u50cf\u5904\u7406\u4e2d\u4f20\u7edf\u81ea\u6ce8\u610f\u529b\u8ba1\u7b97\u590d\u6742\u5ea6\u8fc7\u9ad8\u7684\u95ee\u9898\u3002\u901a\u8fc7\u5377\u79ef\u964d\u7ef4\u3001\u7279\u5f81\u5339\u914d\u548c\u5168\u5c40\u6c60\u5316\u7b49\u6280\u672f\uff0cENLTB\u663e\u8457\u964d\u4f4e\u4e86\u8ba1\u7b97\u91cf(\u590d\u6742\u5ea6\u4eceO(H\u00b2W\u00b2C)\u964d\u4f4e)\uff0c\u540c\u65f6\u4fdd\u6301\u6a21\u578b\u6027\u80fd\u3002\u5b9e\u9a8c\u8868\u660eENLTB\u5728\u56fe\u50cf\u4efb\u52a1\u4e2d\u901f\u5ea6\u63d0\u9ad83-5\u500d\uff0c\u53c2\u6570\u91cf\u51cf\u5c1110%\u4ee5\u4e0a\u3002\u6587\u7ae0\u8be6\u7ec6\u4ecb\u7ecd\u4e86ENLTB\u7684\u67b6\u6784\u8bbe\u8ba1\uff0c\u5305\u62ec\u5377\u79ef\u5339\u914d\u7f51\u7edc\u3001LayerNorm\u3001ENLA\u6a21\u5757\u548cMLP\u524d\u9988\u7f51\u7edc\uff0c\u5e76\u63d0\u4f9b\u4e86PyTorch\u5b9e\u73b0\u4ee3\u7801\u3002\u8be5\u65b9\u6cd5\u7279\u522b\u9002\u5408\u8d44\u6e90\u53d7\u9650\u7684\u5b9e\u65f6\u5e94\u7528\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[152,841,86],"topic":[],"class_list":["post-45137","post","type-post","status-publish","format-standard","hentry","category-server","tag-pytorch","tag-transformer","tag-86"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Efficient Non-Local Transformer Block: \u56fe\u50cf\u5904\u7406\u4e2d\u7684\u9ad8\u6548\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236 - \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\/45137.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Efficient Non-Local Transformer Block: \u56fe\u50cf\u5904\u7406\u4e2d\u7684\u9ad8\u6548\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb430\u6b21\uff0c\u70b9\u8d5e4\u6b21\uff0c\u6536\u85cf5\u6b21\u3002\u672c\u6587\u63d0\u51fa\u4e86\u4e00\u79cd\u9ad8\u6548\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236(ENLA)\u53ca\u5176\u7ec4\u6210\u7684Transformer\u6a21\u5757(ENLTB)\uff0c\u7528\u4e8e\u89e3\u51b3\u56fe\u50cf\u5904\u7406\u4e2d\u4f20\u7edf\u81ea\u6ce8\u610f\u529b\u8ba1\u7b97\u590d\u6742\u5ea6\u8fc7\u9ad8\u7684\u95ee\u9898\u3002\u901a\u8fc7\u5377\u79ef\u964d\u7ef4\u3001\u7279\u5f81\u5339\u914d\u548c\u5168\u5c40\u6c60\u5316\u7b49\u6280\u672f\uff0cENLTB\u663e\u8457\u964d\u4f4e\u4e86\u8ba1\u7b97\u91cf(\u590d\u6742\u5ea6\u4eceO(H\u00b2W\u00b2C)\u964d\u4f4e)\uff0c\u540c\u65f6\u4fdd\u6301\u6a21\u578b\u6027\u80fd\u3002\u5b9e\u9a8c\u8868\u660eENLTB\u5728\u56fe\u50cf\u4efb\u52a1\u4e2d\u901f\u5ea6\u63d0\u9ad83-5\u500d\uff0c\u53c2\u6570\u91cf\u51cf\u5c1110%\u4ee5\u4e0a\u3002\u6587\u7ae0\u8be6\u7ec6\u4ecb\u7ecd\u4e86ENLTB\u7684\u67b6\u6784\u8bbe\u8ba1\uff0c\u5305\u62ec\u5377\u79ef\u5339\u914d\u7f51\u7edc\u3001LayerNorm\u3001ENLA\u6a21\u5757\u548cMLP\u524d\u9988\u7f51\u7edc\uff0c\u5e76\u63d0\u4f9b\u4e86PyTorch\u5b9e\u73b0\u4ee3\u7801\u3002\u8be5\u65b9\u6cd5\u7279\u522b\u9002\u5408\u8d44\u6e90\u53d7\u9650\u7684\u5b9e\u65f6\u5e94\u7528\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/45137.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-06-22T05:19:46+00:00\" \/>\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=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/45137.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/45137.html\",\"name\":\"Efficient Non-Local Transformer Block: \u56fe\u50cf\u5904\u7406\u4e2d\u7684\u9ad8\u6548\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-06-22T05:19:46+00:00\",\"dateModified\":\"2025-06-22T05:19:46+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/45137.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/45137.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/45137.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Efficient Non-Local Transformer Block: \u56fe\u50cf\u5904\u7406\u4e2d\u7684\u9ad8\u6548\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236\"}]},{\"@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":"Efficient Non-Local Transformer Block: \u56fe\u50cf\u5904\u7406\u4e2d\u7684\u9ad8\u6548\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236 - \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\/45137.html","og_locale":"zh_CN","og_type":"article","og_title":"Efficient Non-Local Transformer Block: \u56fe\u50cf\u5904\u7406\u4e2d\u7684\u9ad8\u6548\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb430\u6b21\uff0c\u70b9\u8d5e4\u6b21\uff0c\u6536\u85cf5\u6b21\u3002\u672c\u6587\u63d0\u51fa\u4e86\u4e00\u79cd\u9ad8\u6548\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236(ENLA)\u53ca\u5176\u7ec4\u6210\u7684Transformer\u6a21\u5757(ENLTB)\uff0c\u7528\u4e8e\u89e3\u51b3\u56fe\u50cf\u5904\u7406\u4e2d\u4f20\u7edf\u81ea\u6ce8\u610f\u529b\u8ba1\u7b97\u590d\u6742\u5ea6\u8fc7\u9ad8\u7684\u95ee\u9898\u3002\u901a\u8fc7\u5377\u79ef\u964d\u7ef4\u3001\u7279\u5f81\u5339\u914d\u548c\u5168\u5c40\u6c60\u5316\u7b49\u6280\u672f\uff0cENLTB\u663e\u8457\u964d\u4f4e\u4e86\u8ba1\u7b97\u91cf(\u590d\u6742\u5ea6\u4eceO(H\u00b2W\u00b2C)\u964d\u4f4e)\uff0c\u540c\u65f6\u4fdd\u6301\u6a21\u578b\u6027\u80fd\u3002\u5b9e\u9a8c\u8868\u660eENLTB\u5728\u56fe\u50cf\u4efb\u52a1\u4e2d\u901f\u5ea6\u63d0\u9ad83-5\u500d\uff0c\u53c2\u6570\u91cf\u51cf\u5c1110%\u4ee5\u4e0a\u3002\u6587\u7ae0\u8be6\u7ec6\u4ecb\u7ecd\u4e86ENLTB\u7684\u67b6\u6784\u8bbe\u8ba1\uff0c\u5305\u62ec\u5377\u79ef\u5339\u914d\u7f51\u7edc\u3001LayerNorm\u3001ENLA\u6a21\u5757\u548cMLP\u524d\u9988\u7f51\u7edc\uff0c\u5e76\u63d0\u4f9b\u4e86PyTorch\u5b9e\u73b0\u4ee3\u7801\u3002\u8be5\u65b9\u6cd5\u7279\u522b\u9002\u5408\u8d44\u6e90\u53d7\u9650\u7684\u5b9e\u65f6\u5e94\u7528\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/45137.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-06-22T05:19:46+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/45137.html","url":"https:\/\/www.wsisp.com\/helps\/45137.html","name":"Efficient Non-Local Transformer Block: \u56fe\u50cf\u5904\u7406\u4e2d\u7684\u9ad8\u6548\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-06-22T05:19:46+00:00","dateModified":"2025-06-22T05:19:46+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/45137.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/45137.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/45137.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Efficient Non-Local Transformer Block: \u56fe\u50cf\u5904\u7406\u4e2d\u7684\u9ad8\u6548\u975e\u5c40\u90e8\u6ce8\u610f\u529b\u673a\u5236"}]},{"@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\/45137","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=45137"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/45137\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=45137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=45137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=45137"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=45137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}