{"id":138189,"date":"2020-07-21T06:25:24","date_gmt":"2020-07-20T22:25:24","guid":{"rendered":"http:\/\/4563.org\/?p=138189"},"modified":"2020-07-21T06:25:24","modified_gmt":"2020-07-20T22:25:24","slug":"%e5%85%b3%e4%ba%8e-pytorch-%e6%a8%a1%e5%9e%8b%e5%8f%af%e8%a7%86%e5%8c%96%e7%9a%84%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=138189","title":{"rendered":"\u5173\u4e8e pytorch \u6a21\u578b\u53ef\u89c6\u5316\u7684\u95ee\u9898"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5173\u4e8e pytorch \u6a21\u578b\u53ef\u89c6\u5316\u7684\u95ee\u9898               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Waihinchan <\/span>  <span><i><\/i> 4<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u6700\u8fd1\u5728\u5b66\u4e60 pix2pixHD \u7684\u6a21\u578b.\u57fa\u672c\u4e0a\u5927\u4f53\u90fd\u5bf9\u6a21\u578b\u7684\u7ec6\u8282\u6709\u6240\u4e86\u89e3\u4e86,\u4f46\u662f\u60f3\u50cf\u5728 tensorboard \u91cc\u9762 plot \u4e00\u4e0b\u6a21\u578b.\u53d1\u73b0\u5f88\u591a\u95ee\u9898.\u60f3\u8bf7\u6559\u4e00\u4e0b\u6709\u6ca1\u6709\u4ec0\u4e48\u6bd4\u8f83\u597d\u7684\u65b9\u6cd5\u53ef\u4ee5\u628a\u6a21\u578b\u7684\u7ed3\u6784\u56fe\u7ed9\u6253\u51fa\u6765\u5462? \u6211\u9996\u5148\u8bd5\u4e86\u4e00\u4e0b pytorch \u7684 torch.utils.tensorboard,\u7528\u7684 add_graph \u8fd9\u4e2a\u8981\u6c42\u5199\u4e00\u4e2a dummyinput \u6211\u5c31\u76f4\u63a5\u4ece train \u91cc\u9762\u7684 dataloader \u76f4\u63a5 load \u4e86\u4e00\u4e2a\u6570\u636e,\u7136\u540e\u51fa\u73b0\u7684\u9519\u8bef\u5982\u4e0b: Converting a tensor to a Python index might cause the trace to be incorrect\u2026This means that the trace might not generalize to other inputs! \u5927\u6982\u610f\u601d\u5c31\u662f\u8bf4\u628a tensor \u8f6c\u6210 python \u5c31\u4f1a\u53d8\u6210\u5e38\u91cf\u4ec0\u4e48\u7684,\u7136\u540e\u56fe\u5c31\u6253\u4e0d\u51fa\u6765.<\/p>\n<p>\u6211\u672c\u6765\u5df2\u7ecf hack \u4e86\u4e00\u4e0b\u6a21\u578b\u7684\u6e90\u4ee3\u7801,\u56e0\u4e3a add_graph \u8981\u6c42\u53ea\u6709\u4e00\u4e2a input,\u4f46\u662f\u5b83\u5728 train.py \u811a\u672c\u4e2d\u662f\u6709 4 \u4e2a input \u7684,\u6211\u628a\u5b83\u6253\u5305\u6210\u4e00\u4e2a\u53c2\u6570\u4e4b\u540e\u518d\u5728\u6267\u884c\u4e2d\u81ea\u5df1\u518d\u89e3\u5f00\u4e86. \u5b9e\u9645\u4e0a\u51fa\u73b0\u95ee\u9898\u7684\u597d\u50cf\u662f\u5b83\u672c\u8eab\u5728 forward \u4e2d\u5bf9 tensor \u7684\u4e00\u4e9b\u8f6c\u6362\u51fa\u73b0\u4e86\u95ee\u9898.<\/p>\n<p>\u5b83\u7684\u6e90\u4ee3\u7801\u5199\u7684\u6709\u70b9\u62bd\u8c61,\u5404\u79cd\u5305\u88c5,\u52a0\u4e0a\u521d\u5b66\u5b9e\u5728\u60f3\u8c61\u4e0d\u51fa\u6765\u8fd9\u4e2a\u6a21\u578b(\u5df2\u7ecf\u5927\u6982\u6709\u4e2a\u6570\u4e86,\u4f46\u662f\u60f3\u6253\u5370\u51fa\u6765\u5bf9\u7167\u4e00\u4e0b\u81ea\u5df1\u7406\u89e3\u6709\u6ca1\u6709\u9519)<\/p>\n<p>\u6709\u6ca1\u6709\u4ec0\u4e48\u6bd4\u8f83\u5feb\u901f\u7684\u65b9\u6cd5\u53ef\u4ee5\u5148\u8ba9\u6211\u9884\u89c8\u4e00\u4e0b\u8fd9\u4e2a\u6a21\u578b\u5462?(\u5b9e\u5728\u4e0d\u884c\u6211\u5c31\u53ea\u80fd\u4e00\u4e2a\u4e00\u4e2a\u6a21\u5757\u5728 tf \u91cc\u9762\u590d\u73b0,\u6216\u8005\u628a\u5404\u4e2a\u5c42\u91cd\u65b0\u81ea\u5df1\u5199\u4e00\u6b21\u518d\u7528 summarywriter \u6765\u67e5\u770b\u4e86..)<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>10<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2574574\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : askfermi <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6211\u731c\u8fd9\u4e2a\u5e94\u8be5\u53ef\u4ee5\u6ee1\u8db3\u4f60\u7684\u9700\u8981\uff1a https:\/\/github.com\/lutzroeder\/netron                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2574575\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Waihinchan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @askfermi \u611f\u8c22! \u6211\u8bd5\u4e86\u4e00\u4e0b \u80fd plot \u51fa\u6765\u4f46\u662f\u4f3c\u4e4e\u5c11\u4e86\u5f88\u591a\u4e2a\u5c42,\u597d\u50cf\u5bf9\u4e8e\u4e00\u4e9b resnet \u7684\u7ed3\u6784\u652f\u6301\u7684\u4e0d\u662f\u5f88\u597d\u7684 \u6211\u770b\u4e86\u4e00\u4e0b\u4f5c\u8005\u8bf4\u5bf9\u4e8e pytorch \u662f\u8bd5\u9a8c\u6027\u7684\u652f\u6301.\u4e0d\u8fc7\u8d77\u7801\u80fd\u6709\u5de5\u5177\u4e86~                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2574576\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : leimao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             PyTorch \u4e0d\u662f\u6709 TensorBoard \u5417\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2574577\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : leimao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             OK\uff0c\u6211\u6ca1\u4ed4\u7ec6\u8bfb\uff0c\u4f60\u662f\u61d2\u5f97\u7528 TensorBoard \u3002\u90a3 Netron \u662f\u4f60\u6700\u597d\u7684\u9009\u62e9\u4e86\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2574578\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Waihinchan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @leimao \u4e0d\u662f\u61d2\u5f97\u7528&#8230;\u662f plot \u4e0d\u51fa\u6765 \u6bcf\u6b21\u90fd\u8bf4 trace \u62a5\u9519 \u4f46\u662f\u627e\u4e0d\u5230\u54ea\u91cc\u6709\u95ee\u9898 \u62c6\u4e86\u4e1c\u5899\u8865\u897f\u5899\u90fd\u8fd8\u662f\u4f1a\u62a5\u9519 \u662f input \u597d\u50cf\u4e0d\u592a\u7b26\u5408\u5b83\u7684\u8981\u6c42, \u4f46\u662f\u672c\u8eab\u6a21\u578b\u5df2\u7ecf\u8fde\u6570\u636e\u90fd\u6709\u4e86\u9884\u5904\u7406\u7684\u65b9\u5f0f\u4e86 \u800c\u4e14\u592a\u591a\u53c2\u6570 \u5b9e\u5728\u6ca1\u529e\u6cd5\u4e00\u4e0b\u5b50\u6539\u51fa\u4e00\u4e2a\u80fd\u653e\u5728 tensorboard \u91cc\u7684<br \/>\u6211\u4e2a\u4eba\u8fd8\u662f\u5e0c\u671b\u80fd\u7528 tensorboard \u7684 \u4f46\u6bcf\u4e2a\u4eba\u5199\u7684\u6a21\u578b\u90fd\u6709\u70b9\u4e0d\u540c.. \u7c7b\u4f3c\u53c2\u6570\u7684\u6570\u91cf\u4ec0\u4e48\u7684\u8fd8\u8981\u8c03 \u52a8\u4e00\u52a8\u76f4\u63a5\u6a21\u578b\u90fd\u52a0\u8f7d\u4e0d\u51fa\u6765\u5c31\u5f88\u5934\u5927..                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2574579\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : leimao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Waihinchan \u8fd9\u4e2a tracing \u7684 \u90a3\u4e2a\u4e1c\u897f\u662f\u4e00\u4e2a warning\uff0c\u6211\u6ca1\u8bb0\u9519\u7684\u8bdd\uff0c\u4f7f\u7528\u6765\u751f\u6210 jit \u6216\u8005 onnx \u7528\u7684\uff0c\u4e5f\u5c31\u662f\u7528 dummy input \u628a\u6a21\u578b\u8dd1\u4e00\u904d\u3002\u4f60\u5982\u679c implement \u7684\u4e0d\u6ce8\u610f\uff0c\u5c31\u50cf warning \u8bf4\u7684\uff0c\u8fd9\u4e2a\u4e0d\u80fd generalize\uff0c\u8fd9\u5f88\u53ef\u80fd\u662f\u56e0\u4e3a\u4f60\u4e2d\u95f4\u7528\u4e86 Python \u7684\u53d8\u91cf\u800c\u4e0d\u662f PyTorch \u7684\u53d8\u91cf\u5bfc\u81f4\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2574580\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : leimao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Waihinchan \u6362\u53e5\u8bdd\u8bf4\uff0c\u4f60\u7684\u6a21\u578b\u4e2d\u95f4\u6709\u4e00\u90e8\u5206\u4e1c\u897f\u662f\u5c5e\u4e8e Python \u7684\u800c\u4e0d\u662f\u5c5e\u4e8e\u6a21\u578b\u7684 graph \u7684\uff0c\u6240\u4ee5\u4f60\u6253\u5370\u6a21\u578b\u7684\u65f6\u5019\u4f1a\u5c11\u90a3\u4e00\u90e8\u5206\uff0c\u751a\u81f3\u662f\u62a5\u9519\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2574581\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : leimao <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Waihinchan \u4f60\u8981\u4fee\u70bc\u5230\u770b\u4ee3\u7801\u5c31\u5fc3\u4e2d\u80fd\u770b\u5230 graph \u7684\u5883\u754c\uff0cgraph visualization \u8fd9\u4e1c\u897f\uff0c\u5de5\u7a0b\u4e0a\u7528\u7684\u591a\uff0c\u79d1\u7814\u4e0a\u6ca1\u89c9\u5f97\u6709\u591a\u5927\u7528\u9014\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2574582\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : Waihinchan <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @leimao \u6211\u518d\u8bd5\u8bd5\u2026\u6211\u672c\u6765\u8f93\u5165\u7684\u65f6\u5019\u8fd8\u7279\u610f\u6253\u5370\u4e86\u4e00\u4e0b\u7c7b\u578b\u9a8c\u8bc1\u8fc7 \u53ef\u80fd\u662f\u4e2d\u95f4\u6709\u4e9b\u73af\u8282\u51fa\u4e86\u95ee\u9898\u53c8\u7ed9\u8f6c\u6362\u56de\u53bb\u4e86\u2026                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2574583\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : duaneya <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5bfc\u51fa onnx \u770b\u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5173\u4e8e pytorch \u6a21\u578b\u53ef\u89c6\u5316\u7684&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/138189"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=138189"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/138189\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=138189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=138189"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=138189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}