{"id":202651,"date":"2025-05-22T10:54:59","date_gmt":"2025-05-22T02:54:59","guid":{"rendered":"https:\/\/server.hk\/cnblog\/202651\/"},"modified":"2025-05-22T10:54:59","modified_gmt":"2025-05-22T02:54:59","slug":"java%e5%87%bd%e6%95%b0%e5%bc%8f%e7%bc%96%e7%a8%8b%e5%9c%a8%e6%9c%ba%e5%99%a8%e5%ad%a6%e4%b9%a0%e5%9c%ba%e6%99%af%e4%b8%ad%e7%9a%84%e5%ba%94%e7%94%a8%e6%8e%a2%e8%ae%a8","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/202651\/","title":{"rendered":"Java\u51fd\u6570\u5f0f\u7f16\u7a0b\u5728\u673a\u5668\u5b66\u4e60\u573a\u666f\u4e2d\u7684\u5e94\u7528\u63a2\u8ba8"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Java\u51fd\u6570\u5f0f\u7f16\u7a0b\u5728\u673a\u5668\u5b66\u4e60\u573a\u666f\u4e2d\u7684\u5e94\u7528\u63a2\u8ba8<\/h1>\n<p>\u7f16\u7a0b\u5e76\u4e0d\u662f\u4e00\u4e2a\u673a\u68b0\u6027\u7684\u5de5\u4f5c\uff0c\u800c\u662f\u9700\u8981\u6709\u601d\u8003\uff0c\u6709\u521b\u65b0\u7684\u5de5\u4f5c\uff0c\u8bed\u6cd5\u662f\u56fa\u5b9a\u7684\uff0c\u4f46\u89e3\u51b3\u95ee\u9898\u7684\u601d\u8def\u5219\u662f\u4f9d\u9760\u4eba\u7684\u601d\u7ef4\uff0c\u8fd9\u5c31\u9700\u8981\u6211\u4eec\u575a\u6301\u5b66\u4e60\u548c\u66f4\u65b0\u81ea\u5df1\u7684\u77e5\u8bc6\u3002\u4eca\u5929\u5c31\u6574\u7406\u5206\u4eab\u300aJava\u51fd\u6570\u5f0f\u7f16\u7a0b\u5728\u673a\u5668\u5b66\u4e60\u573a\u666f\u4e2d\u7684\u5e94\u7528\u63a2\u8ba8\u300b\uff0c\u6587\u7ae0\u8bb2\u89e3\u7684\u77e5\u8bc6\u70b9\u4e3b\u8981\u5305\u62ec\uff0c\u5982\u679c\u4f60\u5bf9\u6587\u7ae0\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\u611f\u5174\u8da3\uff0c\u5c31\u4e0d\u8981\u9519\u8fc7\uff0c\u5728\u8fd9\u53ef\u4ee5\u5bf9\u5927\u5bb6\u7684\u77e5\u8bc6\u79ef\u7d2f\u6709\u6240\u5e2e\u52a9\uff0c\u52a9\u529b\u5f00\u53d1\u80fd\u529b\u7684\u63d0\u5347\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729927960671c9b184e356.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>Java \u51fd\u6570\u5f0f\u7f16\u7a0b\u5728\u673a\u5668\u5b66\u4e60\u573a\u666f\u4e2d\u7684\u5e94\u7528<\/strong><\/p>\n<p>\u51fd\u6570\u5f0f\u7f16\u7a0b\uff0c\u4e00\u79cd\u4ee5\u4e0d\u53ef\u53d8\u6570\u636e\u548c\u4e00\u7b49\u51fd\u6570\u4e3a\u6838\u5fc3\u7684\u7f16\u7a0b\u8303\u5f0f\uff0c\u5728\u673a\u5668\u5b66\u4e60\u9886\u57df\u6b63\u9010\u6e10\u5f97\u5230\u5e7f\u6cdb\u5e94\u7528\u3002\u5176\u7b80\u6d01\u3001\u4f18\u96c5\u7684\u7279\u6027\u4f7f\u5176\u6210\u4e3a\u5904\u7406\u673a\u5668\u5b66\u4e60\u95ee\u9898\u7684\u4e0d\u4e8c\u4e4b\u9009\u3002<\/p>\n<p><strong>\u7279\u6027\u548c\u4f18\u52bf<\/strong><\/p>\n<ul>\n<li><strong>\u4e0d\u53ef\u53d8\u6027:<\/strong> \u51fd\u6570\u5f0f\u7f16\u7a0b\u4e2d\u7684\u503c\u662f\u4e0d\u53ef\u53d8\u7684\uff0c\u5728\u51fd\u6570\u6267\u884c\u671f\u95f4\u4e0d\u4f1a\u88ab\u4fee\u6539\uff0c\u8fd9\u7b80\u5316\u4e86\u8c03\u8bd5\u5e76\u63d0\u9ad8\u4e86\u5e76\u53d1\u6027\u3002<\/li>\n<li><strong>\u4e00\u7b49\u51fd\u6570:<\/strong> \u51fd\u6570\u53ef\u4ee5\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u5e76\u4f5c\u4e3a\u8fd4\u56de\u503c\uff0c\u8fd9\u589e\u5f3a\u4e86\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u5e76\u4fc3\u8fdb\u4e86\u4ee3\u7801\u91cd\u7528\u6027\u3002<\/li>\n<\/ul>\n<p><strong>\u5b9e\u6218\u6848\u4f8b\uff1a\u56fe\u50cf\u5206\u7c7b<\/strong><\/p>\n<p>\u8003\u8651\u8fd9\u6837\u4e00\u4e2a\u56fe\u50cf\u5206\u7c7b\u95ee\u9898\uff0c\u6211\u4eec\u5e0c\u671b\u8bad\u7ec3\u4e00\u4e2a\u6a21\u578b\u6765\u8bc6\u522b\u56fe\u50cf\u4e2d\u7684\u732b\u548c\u72d7\u3002\u4f7f\u7528\u51fd\u6570\u5f0f\u7f16\u7a0b\uff0c\u6211\u4eec\u53ef\u4ee5\u5c06\u8be5\u95ee\u9898\u62c6\u89e3\u4e3a\u51e0\u4e2a\u5355\u72ec\u7684\u6b65\u9aa4\uff1a<\/p>\n<pre>\/\/ \u52a0\u8f7d\u56fe\u50cf\u6570\u636e\u96c6\nList&lt;Image&gt; images = loadImages();\n\n\/\/ \u9884\u5904\u7406\u56fe\u50cf\nList&lt;PreprocessedImage&gt; preprocessedImages = images.stream()\n    .map(Image::preprocess)\n    .toList();\n\n\/\/ \u521b\u5efa\u548c\u8bad\u7ec3\u6a21\u578b\nModel model = Model.create()\n    .addLayer(new ConvolutionalLayer(3, 3, 32))\n    .addLayer(new MaxPoolingLayer(2, 2))\n    .addLayer(new FlattenLayer())\n    .addLayer(new DenseLayer(128))\n    .addLayer(new OutputLayer(2));\n\nmodel.train(preprocessedImages);\n\n\/\/ \u8bc4\u4f30\u6a21\u578b\ndouble accuracy = model.evaluate(testImages);<\/pre>\n<p><strong>\u4f18\u70b9<\/strong><\/p>\n<ul>\n<li><strong>\u4ee3\u7801\u7b80\u6d01:<\/strong> \u51fd\u6570\u5f0f\u7f16\u7a0b\u6280\u672f\uff0c\u5982\u96c6\u5408\u64cd\u4f5c\u548c\u03bb\u8868\u8fbe\u5f0f\uff0c\u53ef\u4ee5\u7b80\u5316\u4ee3\u7801\uff0c\u63d0\u9ad8\u53ef\u8bfb\u6027\u3002<\/li>\n<li><strong>\u5e76\u53d1\u6027:<\/strong> \u4e0d\u53ef\u53d8\u6027\u5141\u8bb8\u5728\u591a\u4e2a\u7ebf\u7a0b\u4e0a\u5e76\u884c\u6267\u884c\u4efb\u52a1\uff0c\u4ece\u800c\u63d0\u9ad8\u6027\u80fd\u3002<\/li>\n<li><strong>\u6613\u4e8e\u6d4b\u8bd5:<\/strong> \u51fd\u6570\u5f0f\u7f16\u7a0b\u5f3a\u8c03\u4e0d\u53ef\u53d8\u6027\uff0c\u4f7f\u5355\u5143\u6d4b\u8bd5\u66f4\u5bb9\u6613\u3002<\/li>\n<\/ul>\n<p><strong>\u7ed3\u8bba<\/strong><\/p>\n<p>\u51fd\u6570\u5f0f\u7f16\u7a0b\u4e3a\u673a\u5668\u5b66\u4e60\u5e94\u7528\u5e26\u6765\u4e86\u663e\u8457\u7684\u4f18\u52bf\uff0c\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u6d01\u3001\u9ad8\u6548\u548c\u6613\u4e8e\u7ef4\u62a4\u7684\u7f16\u7a0b\u65b9\u6cd5\u3002\u968f\u7740\u673a\u5668\u5b66\u4e60\u7684\u4e0d\u65ad\u53d1\u5c55\uff0c\u9884\u8ba1\u51fd\u6570\u5f0f\u7f16\u7a0b\u6280\u672f\u7684\u4f7f\u7528\u5c06\u53d8\u5f97\u66f4\u52a0\u666e\u904d\u3002<\/p>\n<p>\u7ec8\u4e8e\u4ecb\u7ecd\u5b8c\u5566\uff01\u5c0f\u4f19\u4f34\u4eec\uff0c\u8fd9\u7bc7\u5173\u4e8e\u300aJava\u51fd\u6570\u5f0f\u7f16\u7a0b\u5728\u673a\u5668\u5b66\u4e60\u573a\u666f\u4e2d\u7684\u5e94\u7528\u63a2\u8ba8\u300b\u7684\u4ecb\u7ecd\u5e94\u8be5\u8ba9\u4f60\u6536\u83b7\u591a\u591a\u4e86\u5427\uff01\u6b22\u8fce\u5927\u5bb6\u6536\u85cf\u6216\u5206\u4eab\u7ed9\u66f4\u591a\u9700\u8981\u5b66\u4e60\u7684\u670b\u53cb\u5427~\u516c\u4f17\u53f7\u4e5f\u4f1a\u53d1\u5e03\u6587\u7ae0\u76f8\u5173\u77e5\u8bc6\uff0c\u5feb\u6765\u5173\u6ce8\u5427\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java\u51fd\u6570\u5f0f\u7f16\u7a0b\u5728\u673a\u5668\u5b66\u4e60\u573a\u666f&#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-202651","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/202651","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=202651"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/202651\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=202651"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=202651"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=202651"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}