{"id":84461,"date":"2020-05-15T20:24:28","date_gmt":"2020-05-15T12:24:28","guid":{"rendered":"http:\/\/4563.org\/?p=84461"},"modified":"2020-05-15T20:24:28","modified_gmt":"2020-05-15T12:24:28","slug":"%e7%9c%9f%e5%bf%83%e6%b1%82%e5%8a%a9%e5%b8%96%ef%bc%8c%e8%af%b7%e9%97%ae%e5%a4%a7%e4%bd%acindexerror-index-799-is-out-of-bounds-for-axis-0-with-size-799%e8%bf%99%e7%a7%8d%e7%b1%bb","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=84461","title":{"rendered":"\u771f\u5fc3\u6c42\u52a9\u5e16\uff0c\u8bf7\u95ee\u5927\u4f6c\u201cIndexError: index 799 is out of bounds for axis 0 with size 799\u201d\u8fd9\u79cd\u7c7b\u578b\u9519\u8bef\u5982\u4f55\u89e3\u51b3\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u771f\u5fc3\u6c42\u52a9\u5e16\uff0c\u8bf7\u95ee\u5927\u4f6c\u201cIndexError: index 799 is out of bounds for axis 0 with size 799\u201d\u8fd9\u79cd\u7c7b\u578b\u9519\u8bef\u5982\u4f55\u89e3\u51b3\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : suifengingo <\/span>  <span><i><\/i> 7<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\">                        \u2744 \u9700\u6c42\u5206\u6790\uff1a<br \/>\u5728\u534a\u76d1\u7763\u8fdb\u884c\u6807\u7b7e\u6807\u6ce8\u65f6\u5019\uff0c\u9047\u5230\u4e86\u201cIndexError: index 799 is out of bounds for axis 0 with size 799\u201d\u8fd9\u79cd\u7c7b\u578b\u7684\u9519\u8bef\uff0c\u767e\u601d\u4e0d\u5f97\u5176\u89e3\uff0c\u5728\u7ebf\u865a\u5fc3\u6c42\u6559\u5927\u4f6c\uff01<\/p>\n<p> [\u6ce8] \uff1a\u5177\u4f53\u662f Billion-scale semi-supervised learning for image classification \u5927\u89c4\u6a21\u56fe\u50cf\u5206\u7c7b\u534a\u76d1\u7763\u5b66\u4e60 \u8bba\u6587\u4e2d\u63d0\u5230\u7684\u8fd9\u4e2a\u9879\u76ee\uff09\uff0c\u8be5\u9879\u76ee\u7684\u5927\u81f4\u6d41\u7a0b\u5982\u4e0b\uff1a<br \/>\u7b2c\u4e00\u6b65\u662f\u4f7f\u7528\u5e26\u6807\u7b7e\u7684\u6570\u636e\u8bad\u7ec3\u51fa\u4e00\u4e2a\u521d\u59cb\u7684 teacher \u6a21\u578b A \uff1b<br \/>\u7b2c\u4e8c\u6b65\u662f\u4f7f\u7528 teacher \u6a21\u578b A \u5728\u65e0\u6807\u7b7e\u7684\u6570\u636e\u4e0a\u505a\u9884\u6d4b\uff0c\u5bf9\u6bcf\u4e2a\u7c7b\u522b\u6807\u7b7e\u7684\u56fe\u50cf\u8fdb\u884c\u6392\u5e8f\uff0c\u6311\u9009\u6700\u597d\u7684 K \u4e2a\u6784\u5efa\u65b0\u7684\u8bad\u7ec3\u6570\u636e\u96c6\uff0c\u5373\u4f2a\u6807\u7b7e\u6570\u636e\u96c6 pseudo-labeled dataset \uff1b<br \/>\u7b2c\u4e09\u6b65\u662f\u4f7f\u7528\u6784\u5efa\u7684\u6570\u636e\u96c6 pre-training \u9884\u8bad\u7ec3\u51fa\u4e00\u4e2a student \u6a21\u578b B \uff1b<br \/>\u6700\u540e\uff0c\u5c06\u8bad\u7ec3\u5f97\u5230\u7684 student \u6a21\u578b B \u653e\u5728\u6700\u5f00\u59cb\u7684\u6709\u6807\u7b7e\u6570\u636e\u4e0a\u505a fine-tune \u5fae\u8c03\uff0c\u6765\u51cf\u5c11\u6f5c\u5728\u7684\u8bef\u6807\u7b7e\u60c5\u51b5\u3002<\/p>\n<p>\u5177\u4f53\u662f\u5728\u8fdb\u884c\u5230\u7b2c\u4e8c\u6b65\u7684\u65f6\u5019\uff0c\u62a5\u51fa\u4e86\u4e0a\u8ff0\u7684\u9519\u8bef\u4fe1\u606f\uff0c\u5168\u7a0b\u662f\u4e25\u683c\u6309\u7167\u9879\u76ee\u6765\u8fdb\u884c\u7684\uff0c\u7b2c\u4e00\u6b65\u4e2d\u7684\u6a21\u578b\u5df2\u8bad\u7ec3\u5b8c\u6210\u3002\u5206\u6790\u8fc7\u540e\uff0c\u62a5\u9519\u4fe1\u606f\u5b9a\u4f4d\u5230\u5728\u7b2c\u4e8c\u6b65\u4ee3\u7801\u6587\u4ef6\u7684 select_top_k()\u51fd\u6570\u4e2d\uff08\u5177\u4f53\u7684\u51fd\u6570\u4ee3\u7801\u5df2\u5728\u4e0b\u65b9\u5217\u51fa\uff0c\u4e3a\u4e86\u65b9\u4fbf\u6307\u5bfc\uff0c\u5df2\u5c06\u6bcf\u884c\u4ee3\u7801\u7684\u884c\u53f7\u6807\u51fa\uff09\uff0c\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528\u662f\u5c06\u4ece json \u6587\u4ef6\u4e2d\u63d0\u53d6\u51fa\u7684\u952e\u503c\u5bf9\u6309\u7167 key \u5143\u7d20\u964d\u5e8f\u6392\u5217\uff0c\u9009\u51fa\u524d k \u4e2a\u5143\u7d20\uff0c\u7a0b\u5e8f\u4e5f\u6b63\u662f\u8fd0\u884c\u5230\u8fd9\u4e2a\u5730\u65b9\u51fa\u73b0\u4e86\u62a5\u9519\u3002\u81ea\u5df1\u6709\u5bf9\u8be5\u51fd\u6570\u7684\u7b2c 14 \u884c\u4ee3\u7801\u8fdb\u884c\u4fee\u6539\uff0c\u4f46\u53d1\u73b0\u65e0\u6d4e\u4e8e\u4e8b\uff0c\u5e94\u8be5\u662f\u6ca1\u6709 get \u5230\u771f\u6b63\u7684\u9519\u8bef\u6240\u5728\uff0c\u7531\u4e8e\u672c\u4eba\u77e5\u8bc6\u532e\u4e4f\uff0c\u5b9e\u5728\u4e0d\u77e5\u5982\u4f55 Debug \u8be5\u9519\u8bef\u4fe1\u606f\uff0c\u5728\u6b64\u865a\u5fc3\u5411\u5927\u4f6c\u8bf7\u6559\uff0c\u5148\u8bf4\u58f0\u8c22\u8c22\u4e86\uff01<\/p>\n<p>\u2744 \u5177\u4f53\u62a5\u9519\u4fe1\u606f\u5982\u4e0b\uff1a<br \/>Load Model Accuracy: 75.64 Load Model end epoch: 100<br \/>class name: apple<br \/>image data count: 210<br \/>class name: aquarium_fish<br \/>image data count: 203<br \/>class name: baby<br \/>image data count: 151<br \/>class name: bear<br \/>image data count: 189<br \/>&#8230;<br \/>class name: wolf<br \/>image data count: 212<br \/>class name: woman<br \/>image data count: 199<br \/>class name: worm<br \/>image data count: 173<br \/>Saving.. sampling_dict<br \/>label: 39<br \/>each label item count: 18779<br \/>label: 82<br \/>each label item count: 18779<br \/>label: 20<br \/>each label item count: 18626<br \/>label: 0<br \/>each label item count: 18340<br \/>label: 9<br \/>each label item count: 13232<br \/>label: 6<br \/>each label item count: 5547<br \/>label: 3<br \/>each label item count: 17344<br \/>label: 16<br \/>each label item count: 4228<br \/>label: 2<br \/>each label item count: 17960<br \/>label: 24<br \/>each label item count: 1880<br \/>label: 10<br \/>each label item count: 1581<br \/>label: 5<br \/>each label item count: 14524<br \/>label: 4<br \/>each label item count: 16767<br \/>label: 61<br \/>each label item count: 799<br \/>Traceback (most recent call last):<br \/> File &#8220;make_sample_data_1.py&#8221;, line 155, in &lt;module&gt;<br \/> main(args)<br \/> File &#8220;make_sample_data_1.py&#8221;, line 148, in main<br \/> select_top_k(args.k)<br \/> File &#8220;make_sample_data_1.py&#8221;, line 128, in select_top_k<br \/> sampled_image_dict[&#8220;all&#8221;].append([all_items[index][0], int(key)])<br \/>IndexError: index 799 is out of bounds for axis 0 with size 799<\/p>\n<p>\u2744 \u76f8\u5173\u4ee3\u7801\u7247\u6bb5\uff1a<br \/> 1 def select_top_k(k=1000):<br \/> 2 sampled_image_dict = {}<br \/> 3 sampled_image_dict[&#8220;all&#8221;] = []<br \/> 4 with codecs.open(&#8220;.\/sampling_dict.json&#8221;, &#8220;r&#8221;, encoding=&#8221;utf-8&#8243;, errors=&#8221;ignore&#8221;) as f:<br \/> 5 load_data = json.load(f)<br \/> 6 <br \/> 7 for key in load_data.keys():<br \/> 8 print(&#8220;label: &#8220;, key)<br \/> 9 all_items = load_data[key]<br \/> 10 all_items.sort(key=lambda x: x[1], reverse=True)<br \/> 11 all_items = np.array(all_items)<br \/> 12 print(&#8220;each label item count: &#8220;, len(all_items))<br \/> 13 for index in range(0, k):<br \/> 14 sampled_image_dict[&#8220;all&#8221;].append([all_items[index][0], int(key)])<br \/> 15 <br \/> 16 print(&#8220;Saving.. selected image json&#8221;)<br \/> 17 j = json.dumps(sampled_image_dict)<br \/> 18 with open(&#8220;selected_image.json&#8221;, &#8220;w&#8221;) as f:<br \/> 19 f.write(j)      <\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>0<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u771f\u5fc3\u6c42\u52a9\u5e16\uff0c\u8bf7\u95ee\u5927\u4f6c\u201cIndexE&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\/84461"}],"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=84461"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/84461\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=84461"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=84461"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=84461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}