{"id":2467,"date":"2021-11-01T15:41:21","date_gmt":"2021-11-01T07:41:21","guid":{"rendered":"http:\/\/www.yatenglg.cn\/?p=2467"},"modified":"2022-10-18T16:34:39","modified_gmt":"2022-10-18T08:34:39","slug":"repvgg","status":"publish","type":"post","link":"http:\/\/www.yatenglg.cn\/blog\/?p=2467","title":{"rendered":"RepVGG-\u6781\u7b80\u67b6\u6784\uff0cSOTA\u6027\u80fd\uff0c\u8ba9VGG\u5f0f\u6a21\u578b\u518d\u6b21\u4f1f\u5927"},"content":{"rendered":"\n<p>\u8bba\u6587\u94fe\u63a5\uff1a<a href=\"https:\/\/arxiv.org\/abs\/2101.03697\">https:\/\/arxiv.org\/abs\/2101.03697<\/a><\/p>\n\n\n\n<p>RepVGG\u63d0\u51fa <strong>\u5728\u8bad\u7ec3\u65f6\uff0c\u8bad\u7ec3\u4e00\u4e2a\u591a\u5206\u652f\u7f51\u7edc\uff0c\u4ee5\u63d0\u9ad8\u6a21\u578b\u7cbe\u5ea6\uff1b\u5728\u68c0\u6d4b\u65f6\uff0c\u5c06\u8bad\u7ec3\u7684\u591a\u5206\u652f\u7f51\u7edc\u7b49\u4ef7\u88c5\u6362\u4e3a\u4e00\u4e2a\u5355\u5206\u652f\u7f51\u7edc\uff0c\u4ee5\u63d0\u9ad8\u8fd0\u884c\u901f\u5ea6\u3002<\/strong><\/p>\n\n\n\n<p>\u6a21\u578b\u7ed3\u6784\u65b9\u9762\uff0c\u4f7f\u75283&#215;3\u5377\u79ef\u5806\u53e0\uff0c\u6784\u5efa\u6a21\u578b\u3002\u8bad\u7ec3\u65f6\uff0c\u6a21\u578b\u901a\u8fc71&#215;1\u5377\u79ef\u8ba1\u7b97\u6b8b\u5dee\uff0c\u5e76\u901a\u8fc7identity\u5c42\u77ed\u8def\u8fde\u63a5\u8fdb\u884c\u6052\u7b49\u6620\u5c04\uff1b\u5728\u90e8\u7f72\u65f6\uff0c\u5c06\u6a21\u578b\u4e2d\u6b8b\u5dee\u8fde\u63a5\u4e0e\u77ed\u8def\u8fde\u63a5\u8fdb\u884c\u7b49\u4ef7\u8f6c\u6362\uff0c\u5f62\u6210\u5355\u5206\u652f\u6a21\u578b\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img src=\"https:\/\/pic2.zhimg.com\/v2-68f9808932d8923677a9c989c98725f9_r.jpg\" alt=\"preview\"\/><\/figure>\n\n\n\n<p>\u8fdb\u884c\u7b49\u4ef7\u8f6c\u6362\u65f6\uff0c\u4e3b\u8981\u601d\u60f3\u4e3a\uff1aconv(x, w1) + conv(x, w2) + conv(x, w3) = conv(x ,w1 + w2 + w3)\u3002\u8f6c\u6362\u65f6\uff0c\u5c06identity\u89c6\u4f5c\u6838\u503c\u56fa\u5b9a\u4e3a1\u76841&#215;1\u5377\u79ef\uff0c\u5c061&#215;1\u5377\u79ef\u6838padding0\u5f62\u4e3a3&#215;3\u5377\u79ef\u6838\uff0c\u7136\u540e\u5408\u5e763&#215;3\u4e0e1&#215;1\u5377\u79ef\u6838\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism undefined-numbers lang-python\" data-lang=\"Python\"><code># -*- coding: utf-8 -*-\n# @Author  : LG\n\nimport torch\nfrom torch.nn import functional as f\nimport numpy as np\n\nif __name__ == &#39;__main__&#39;:\n\n    # \u4e00\u4e2a3x3\u7684\u8f93\u5165\n    input = torch.from_numpy(np.array([[[[1, 2, 3],\n                                       [4, 5, 6],\n                                       [7, 8, 9]]]]))\n    # 3x3\u5377\u79ef\u6838\n    weight_3x3 = torch.tensor([[[[1,2,1], [2,1,2], [1,3,2]]]])\n    conv_3x3 = f.conv2d(input, weight=weight_3x3, stride=1,padding=1)\n\n    print(conv_3x3)\n\n    # 1x1\u5377\u79ef\u6838\n    weight_1x1 = torch.tensor([[[[2]]]])\n    conv_1x1 = f.conv2d(input, weight=weight_1x1, stride=1)\n    print(conv_1x1)\n\n    # \u8fd9\u91ccidentity \u53ef\u4ee5\u770b\u4f5c\u503c\u4e3a1\u76841x1\u5377\u79ef\n    weight_identity = torch.tensor([[[[1]]]])\n    identity = f.conv2d(input, weight=weight_identity, stride=1)\n    print(identity)\n\n    # \u76f8\u52a0\u5408\u5e76\u7ed3\u679c\n    result = conv_3x3 + conv_1x1 + identity\n    print(result)\n\n    # \u5148\u5408\u5e76\u5377\u79ef\u6838\uff0c\u7136\u540e\u8ba1\u7b97\u3002\n    # 1x1\u5377\u79ef\u9700\u8981padding0 \u4f5c\u4e3a\u4e00\u4e2a3x3\u5377\u79ef\u6838\uff0c\u7136\u540e\u76f8\u52a0\n    weight_merge = weight_3x3 + f.pad(weight_1x1, [1, 1, 1, 1]) + f.pad(weight_identity, [1, 1, 1, 1])\n    print(weight_merge)\n    # \u5355\u6b21\u5377\u79ef\u8ba1\u7b97\uff0c\u7ed3\u679c\u76f8\u540c\n    conv_merge = f.conv2d(input, weight_merge, stride=1, padding=1)\n    print(conv_merge)\n<\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u8bba\u6587\u94fe\u63a5\uff1ahttps:\/\/arxiv.org\/abs\/2101.03697 RepVGG\u63d0\u51fa \u5728\u8bad\u7ec3\u65f6\uff0c\u8bad\u7ec3\u4e00&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[8,5],"tags":[],"_links":{"self":[{"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2467"}],"collection":[{"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2467"}],"version-history":[{"count":17,"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2467\/revisions"}],"predecessor-version":[{"id":2484,"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=\/wp\/v2\/posts\/2467\/revisions\/2484"}],"wp:attachment":[{"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2467"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.yatenglg.cn\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}