{"id":204999,"date":"2025-05-29T16:53:08","date_gmt":"2025-05-29T08:53:08","guid":{"rendered":"https:\/\/server.hk\/cnblog\/204999\/"},"modified":"2025-05-29T16:53:08","modified_gmt":"2025-05-29T08:53:08","slug":"%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0%e8%ae%ad%e7%bb%83%e6%97%b6%e7%a8%8b%e5%ba%8f%e7%aa%81%e7%84%b6%e9%80%80%e5%87%ba%ef%bc%8c%e9%94%99%e8%af%af%e4%bb%a3%e7%a0%81%e4%b8%ba-1073741571%ef%bc%8c","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/204999\/","title":{"rendered":"\u6df1\u5ea6\u5b66\u4e60\u8bad\u7ec3\u65f6\u7a0b\u5e8f\u7a81\u7136\u9000\u51fa\uff0c\u9519\u8bef\u4ee3\u7801\u4e3a -1073741571\uff0c\u600e\u4e48\u89e3\u51b3\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>\u6df1\u5ea6\u5b66\u4e60\u8bad\u7ec3\u65f6\u7a0b\u5e8f\u7a81\u7136\u9000\u51fa\uff0c\u9519\u8bef\u4ee3\u7801\u4e3a -1073741571\uff0c\u600e\u4e48\u89e3\u51b3\uff1f<\/h1>\n<p>\u79ef\u7d2f\u77e5\u8bc6\uff0c\u80dc\u8fc7\u79ef\u84c4\u91d1\u94f6\uff01\u6bd5\u7adf\u5728\u6587\u7ae0\u5f00\u53d1\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4f1a\u9047\u5230\u5404\u79cd\u5404\u6837\u7684\u95ee\u9898\uff0c\u5f80\u5f80\u90fd\u662f\u4e00\u4e9b\u7ec6\u8282\u77e5\u8bc6\u70b9\u8fd8\u6ca1\u6709\u638c\u63e1\u597d\u800c\u5bfc\u81f4\u7684\uff0c\u56e0\u6b64\u57fa\u7840\u77e5\u8bc6\u70b9\u7684\u79ef\u7d2f\u662f\u5f88\u91cd\u8981\u7684\u3002\u4e0b\u9762\u672c\u6587\u300a\u6df1\u5ea6\u5b66\u4e60\u8bad\u7ec3\u65f6\u7a0b\u5e8f\u7a81\u7136\u9000\u51fa\uff0c\u9519\u8bef\u4ee3\u7801\u4e3a -1073741571\uff0c\u600e\u4e48\u89e3\u51b3\uff1f\u300b\uff0c\u5c31\u5e26\u5927\u5bb6\u8bb2\u89e3\u4e00\u4e0b\u77e5\u8bc6\u70b9\uff0c\u82e5\u662f\u4f60\u5bf9\u672c\u6587\u611f\u5174\u8da3\uff0c\u6216\u8005\u662f\u60f3\u641e\u61c2\u5176\u4e2d\u67d0\u4e2a\u77e5\u8bc6\u70b9\uff0c\u5c31\u8bf7\u4f60\u7ee7\u7eed\u5f80\u4e0b\u770b\u5427~<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241121\/1732164525673ebbada4dec.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>python \u7a0b\u5e8f\u5728 windows \u4e0a\u7a81\u7136\u9000\u51fa\uff0c\u9519\u8bef\u4ee3\u7801\u4e3a -1073741571<\/strong><\/p>\n<p>\u5728 pycharm \u4e2d\u8fd0\u884c\u6df1\u5ea6\u5b66\u4e60\u8bad\u7ec3\u65f6\uff0c\u7a0b\u5e8f\u53ef\u80fd\u4f1a\u7a81\u7136\u7ed3\u675f\uff0c\u9000\u51fa\u4ee3\u7801\u4e3a -1073741571\u3002\u6b64\u9519\u8bef\u8868\u660e\u7a0b\u5e8f\u9047\u5230\u4e86\u672a\u5904\u7406\u7684\u5f02\u5e38\u3002<\/p>\n<p><strong>\u539f\u56e0\u5206\u6790<\/strong><\/p>\n<p>\u7ecf\u8fc7\u4ed4\u7ec6\u68c0\u67e5\u6e90\u4ee3\u7801\uff0c\u53d1\u73b0\u95ee\u9898\u51fa\u5728\u4ee5\u4e0b\u4ee3\u7801\u5757\u4e2d\uff1a<\/p>\n<pre>for j in range(images.size(0)):\n  loss_list[index[j]] = loss[j]<\/pre>\n<p>\u5728\u8fd9\u91cc\uff0closs_list \u88ab\u521d\u59cb\u5316\u4e3a\u4e00\u4e2a\u5b58\u50a8\u6d6e\u70b9\u6570\u7684 pytorch \u5f20\u91cf\u3002\u7136\u800c\uff0closs \u662f\u4e00\u4e2a\u5f20\u91cf\uff0c\u5176\u4e2d\u5305\u542b\u8bad\u7ec3\u6279\u6b21\u4e2d\u6bcf\u4e2a\u6837\u672c\u7684\u635f\u5931\u503c\u3002\u56e0\u6b64\uff0c\u5c06\u5f20\u91cf\u5206\u914d\u7ed9\u6d6e\u70b9\u6570\u4f1a\u5bfc\u81f4\u95ee\u9898\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u5c06 loss_list \u521d\u59cb\u5316\u4e3a numpy \u6570\u7ec4\uff0c\u800c\u4e0d\u662f pytorch \u5f20\u91cf\uff0c\u53ef\u4ee5\u89e3\u51b3\u6b64\u95ee\u9898\uff1a<\/p>\n<pre>loss_list = np.zeros(len(dataloader.dataset))<\/pre>\n<p>\u8fd9\u6837\uff0closs_list \u5c31\u53ef\u4ee5\u5b58\u50a8\u6d6e\u70b9\u6570\uff0c\u5e76\u4e14\u53ef\u4ee5\u6b63\u786e\u5730\u4fdd\u5b58\u6bcf\u4e2a\u6837\u672c\u7684\u635f\u5931\u503c\u3002<\/p>\n<p><strong>\u5176\u4ed6\u6539\u8fdb<\/strong><\/p>\n<p>\u6b64\u5916\uff0c\u5982\u679c\u4e0d\u9700\u8981\u4e3a\u6536\u96c6\u7684\u635f\u5931\u8ba1\u7b97\u68af\u5ea6\uff0c\u53ef\u4ee5\u8fdb\u4e00\u6b65\u6539\u8fdb\u4ee3\u7801\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>for j in range(batch_size):\n  loss_list[index[j]] = loss[j].item()<\/pre>\n<p>\u8fd9\u5c06\u4ece\u5f20\u91cf\u4e2d\u63d0\u53d6\u539f\u59cb\u6d6e\u70b9\u6570\uff0c\u4ece\u800c\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u5185\u5b58\u6d88\u8017\u548c\u68af\u5ea6\u8ba1\u7b97\u3002<\/p>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6df1\u5ea6\u5b66\u4e60\u8bad\u7ec3\u65f6\u7a0b\u5e8f\u7a81\u7136\u9000\u51fa\uff0c\u9519\u8bef&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-204999","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204999","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=204999"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/204999\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=204999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=204999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=204999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}